当前位置: 首页>>代码示例>>C++>>正文


C++ population::push_front方法代码示例

本文整理汇总了C++中population::push_front方法的典型用法代码示例。如果您正苦于以下问题:C++ population::push_front方法的具体用法?C++ population::push_front怎么用?C++ population::push_front使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在population的用法示例。


在下文中一共展示了population::push_front方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: increase_tree_depth

 void increase_tree_depth(generation_table& gtable, population& pop, int& from_depth, combo::arity_t& needed_arg_count, int fill_from_arg, const reduct::rule& reduction_rule) {
     for (population::iterator it = pop.begin(); it != pop.end(); ++it) {
         int number_of_combinations = 1;
         bool can_have_leaves = false;
         std::vector<generation_table::iterator> assignment;
         std::vector<combo::combo_tree::leaf_iterator> leaves;
         for (combo::combo_tree::leaf_iterator lit = it->begin_leaf(); lit != it->end_leaf(); ++lit) {
             if (combo::is_argument(*lit))
                 if (combo::get_argument(*lit).abs_idx() <= needed_arg_count)
                     continue;
             for (std::vector<generation_node>::iterator it2 = gtable.begin(); it2 != gtable.end(); it2++)
                 if (combo::equal_type_tree(it2->node, combo::infer_vertex_type(*it, lit))) {
                     if (it2->glist.size() != 0)
                         can_have_leaves = true;
                     assignment.push_back(it2);
                     number_of_combinations *= it2->glist.size();                        
                     break;
                 }
         }
         if (!can_have_leaves)
             number_of_combinations = 0;
         for (int i = 0; i < number_of_combinations; i++) {
             combo::combo_tree temp_tree(*it);
             int ongoing_count = 1;
             leaves.clear();
             for (combo::combo_tree::leaf_iterator lit = temp_tree.begin_leaf(); lit != temp_tree.end_leaf(); ++lit)
                 leaves.push_back(lit);
             std::vector<generation_table::iterator>::iterator it2 = assignment.begin();
             for (std::vector<combo::combo_tree::leaf_iterator>::iterator lit = leaves.begin(); lit != leaves.end(); ++lit) {
                 if (combo::is_argument(**lit))
                     if (combo::get_argument(**lit).abs_idx() <= needed_arg_count)
                        continue;
                 if ((*it2)->glist.size() != 0) {
                     node_list::iterator it3 = (*it2)->glist.begin();
                     for (int n = 0; n < (int)(i/(number_of_combinations/(ongoing_count * (*it2)->glist.size())) % (*it2)->glist.size()); n++)
                         it3++;
                     temp_tree.replace(*lit, *it3);
                     ongoing_count *= (*it2)->glist.size();
                 }
                 it2++;
             }
             bool erased = true;
             for (combo::combo_tree::leaf_iterator lit = temp_tree.begin_leaf(); lit != temp_tree.end_leaf(); ++lit) {
                 if (combo::get_arity(*lit) != 0 && !combo::is_argument(*lit)) {
                     erased = false;
                     break;
                 }
             }
             if (combo::does_contain_all_arg_up_to(temp_tree, needed_arg_count)) {
                 erased = false;
             }
             if (!erased) {
                 //Uses less memory but is very slow
                 /*fill_leaves_single(temp_tree, fill_from_arg);
                 reduced_insertion(new_pop, temp_tree, reduction_rule);*/
                 pop.push_front(temp_tree);
             }
         }
     }
 }
开发者ID:Spydrouge,项目名称:opencog_Spydr,代码行数:60,代码来源:generation.cpp


注:本文中的population::push_front方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。