本文整理汇总了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);
}
}
}
}