//--------------------------------------------------------- int main() { std::vector<int> v, w; std::vector<Base*> x, y, z; std::vector<Base*>* u=new std::vector<Base*>(); for(int i=0; i<10; ++i) v.push_back(i); for(int i=0; i<10; ++i) x.push_back(new Base(i)); /////////////////////////////////////////////////// copy_if(v.begin(), v.end(), back_inserter(w), IsOdd()); copy_if(x.begin(), x.end(), back_inserter(y), BaseIsOdd()); copy_if(x.begin(), x.end(), back_inserter(*u), BaseIsOdd()); copy_if(x.begin(), x.end(), back_inserter(z), std::not1(BaseIsOdd())); /////////////////////////////////////////////////// for(std::vector<int>::iterator it=w.begin(); it!=w.end(); ++it) std::cout<<*it<<" "; std::cout<<std::endl; for(std::vector<Base*>::iterator it=y.begin(); it!=y.end(); ++it) std::cout<<(*it)->_n<<" "; std::cout<<std::endl; for(std::vector<Base*>::iterator it=z.begin(); it!=z.end(); ++it) std::cout<<(*it)->_n<<" "; std::cout<<std::endl; for(std::vector<Base*>::iterator it=u->begin(); it!=u->end(); ++it) std::cout<<(*it)->_n<<" "; std::cout<<std::endl; /////////////////////////////////////////////////// //std::vector<int>::back_insert_iterator it=copy_if(v.begin(), v.end(), back_inserter(w), IsOdd()); /////////////////////////////////////////////////// return 0; }
int TargetSelectionObjective::v_heuristicVariable( const vector< int > &vecId, const vector< Unit > *vecVariables, TargetSelectionDomain *domain ) { // select first units that are about to shoot, and then splash units first among them. auto min = min_element( vecId.begin(), vecId.end(), [&](int b1, int b2) { return vecVariables->at(b1).canShootIn() < vecVariables->at(b2).canShootIn(); } ); vector< int > varMinShoot( vecId.size() ); auto it_shoot = copy_if( vecId.begin(), vecId.end(), varMinShoot.begin(), [&](int b){return vecVariables->at(b).canShootIn() == *min;} ); if( it_shoot == varMinShoot.begin() ) return vecId[ randomVar.getRandNum( vecId.size() ) ]; varMinShoot.resize( distance( varMinShoot.begin(), it_shoot ) ); varMinShoot.shrink_to_fit(); vector< int > varSplash( varMinShoot.size() ); auto it_splash = copy_if( varMinShoot.begin(), varMinShoot.end(), varSplash.begin(), [&](int b){return vecVariables->at(b).isSplash();} ); // cout << "varMinShoot.size() = " << varMinShoot.size() << endl; if( it_splash == varSplash.begin() ) return varMinShoot[ randomVar.getRandNum( varMinShoot.size() ) ]; else return varSplash[ randomVar.getRandNum( distance( varSplash.begin(), it_splash ) ) ]; }
void copy_if( BEGIN begin , END end , DBEGIN d_begin , F f ) { if( begin != end ) { if( f( *begin ) ) { auto next = ttl::assign( d_begin , *begin ); copy_if( ++begin , end , ++next , f ); } else copy_if( ++begin , end , d_begin , f ); } }
void ChrRegionCluster::getOverlaps(int start, int end, std::vector<const ChrRegion*>& regions) const { copy_if(elts.begin(), elts.end(), back_inserter(regions), [start, end](const ChrRegion *cr) { return ((start >= cr->getStartPos() && start < cr->getEndPos()) || (cr->getStartPos() >= start && cr->getStartPos() < end)); }); }
void AIGraph::gatherExternalNodesNear(const glm::vec3& center, const float radius, std::vector<AIGraphNode*>& nodes, NodeType type) { // the bounds end up covering more than might fit auto planecoords = glm::vec2(center); auto minWorld = planecoords - glm::vec2(radius); auto maxWorld = planecoords + glm::vec2(radius); auto minGrid = worldToGrid(minWorld); auto maxGrid = worldToGrid(maxWorld); for (int x = minGrid.x; x <= maxGrid.x; ++x) { for (int y = minGrid.y; y <= maxGrid.y; ++y) { int i = (x * WORLD_GRID_WIDTH) + y; if (i < 0 || i >= static_cast<int>(gridNodes.size())) { continue; } auto& external = gridNodes[i]; copy_if(external.begin(), external.end(), back_inserter(nodes), [¢er, &radius, &type](const auto node) { return node->type == type && glm::distance2(center, node->position) < radius * radius; }); } } }
void generate(OutputIterator first, OutputIterator last, Generator &generator, command_queue &queue) { size_t size = std::distance(first, last); typedef typename Generator::result_type g_result_type; vector<g_result_type> tmp(size, queue.get_context()); vector<g_result_type> tmp2(size, queue.get_context()); uint_ bound = ((uint_(-1))/(m_b-m_a+1))*(m_b-m_a+1); buffer_iterator<g_result_type> tmp2_iter; while(size>0) { generator.generate(tmp.begin(), tmp.begin() + size, queue); tmp2_iter = copy_if(tmp.begin(), tmp.begin() + size, tmp2.begin(), _1 <= bound, queue); size = std::distance(tmp2_iter, tmp2.end()); } BOOST_COMPUTE_FUNCTION(IntType, scale_random, (const g_result_type x), { return LO + (x % (HI-LO+1)); });
int _tmain(int argc, _TCHAR* argv[]) { typedef std::vector<int> ContainerType; ContainerType ct1; ContainerType ct2; for(int i = 0; i < 10; ++i) { ct1.push_back(i); ct1.push_back(5); } copy_if( ct1.begin(), ct1.end(), std::inserter( ct2, ct2.begin()), TypeComperator<ContainerType::value_type>(5)); std::for_each(ct2.begin(), ct2.end(), Print()); return 0; }
std::vector<BsaAsset> GenericBsa::GetMatchingAssets(const regex& regex) const { vector<BsaAsset> matchingAssets; copy_if(begin(assets), end(assets), back_inserter(matchingAssets), [&](const BsaAsset& asset) { return regex_match(asset.path, regex); }); return matchingAssets; }
void Rest::getMarket(Mnem contrMnem, Time now, std::ostream& out) const { const auto& markets = serv_.markets(); out << '['; copy_if(markets.begin(), markets.end(), OStreamJoiner(out, ','), [contrMnem](const auto& market) { return market.contr() == contrMnem; }); out << ']'; }
void Rest::getPosn(Mnem accntMnem, Mnem contrMnem, Time now, ostream& out) const { const auto& accnt = serv_.accnt(accntMnem); const auto& posns = accnt.posns(); out << '['; copy_if(posns.begin(), posns.end(), OStreamJoiner(out, ','), [contrMnem](const auto& posn) { return posn.contr() == contrMnem; }); out << ']'; }
void Rest::getTrade(Mnem accntMnem, Mnem contrMnem, Time now, std::ostream& out) const { const auto& accnt = serv_.accnt(accntMnem); const auto& trades = accnt.trades(); out << '['; copy_if(trades.begin(), trades.end(), OStreamJoiner(out, ','), [contrMnem](const auto& trade) { return trade.contr() == contrMnem; }); out << ']'; }
void Rest::getOrder(Mnem accntMnem, Mnem contrMnem, Time now, ostream& out) const { const auto& accnt = serv_.accnt(accntMnem); const auto& orders = accnt.orders(); out << '['; copy_if(orders.begin(), orders.end(), OStreamJoiner(out, ','), [contrMnem](const auto& order) { return order.contr() == contrMnem; }); out << ']'; }
void Rest::getTrade(Mnem accntMnem, Mnem contrMnem, IsoDate settlDate, Time now, ostream& out) const { const auto& accnt = serv_.accnt(accntMnem); const auto& contr = serv_.contr(contrMnem); const auto marketId = toMarketId(contr.id(), settlDate); const auto& trades = accnt.trades(); out << '['; copy_if(trades.begin(), trades.end(), OStreamJoiner(out, ','), [marketId](const auto& trade) { return trade.marketId() == marketId; }); out << ']'; }
int main() { std::vector<int> numbers; numbers.push_back(0); numbers.push_back(1); numbers.push_back(2); numbers.push_back(3); std::vector<int> copy; // Functor: Ok copy_if(numbers.begin(), numbers.end(), std::back_inserter(copy), is_odd_functor()); // Function pointer: Ok copy_if(numbers.begin(), numbers.end(), std::back_inserter(copy), is_odd); // Function pointer that takes const ref: Compiler error copy_if(numbers.begin(), numbers.end(), std::back_inserter(copy), is_odd_const_ref); return 0; }
void Sequencer::filter(PSortedRun run, SearchQuery const& q, std::vector<PSortedRun>* results) const { if (run->empty()) { return; } SearchPredicate search_pred(q); PSortedRun result(new SortedRun); auto lkey = TimeSeriesValue(q.lowerbound, 0u, 0u, 0u); auto rkey = TimeSeriesValue(q.upperbound, ~0u, 0u, 0u); auto begin = std::lower_bound(run->begin(), run->end(), lkey); auto end = std::upper_bound(run->begin(), run->end(), rkey); copy_if(begin, end, std::back_inserter(*result), search_pred); results->push_back(move(result)); }
Word::Word(std::string const &inputString) { if (inputString.empty()) { throw std::invalid_argument("empty string supplied"); } copy_if(inputString.cbegin(), inputString.cend(), std::back_inserter(rep), [](char const character) { if (!std::isalpha(character)) { throw std::invalid_argument("invalid character in input"); } return true; }); }
typename util::detail::algorithm_result< ExPolicy, hpx::util::tagged_pair< tag::in(typename traits::range_traits<Rng>::iterator_type), tag::out(OutIter) > >::type copy_if(ExPolicy && policy, Rng && rng, OutIter dest, F && f, Proj && proj = Proj()) { return copy_if(std::forward<ExPolicy>(policy), boost::begin(rng), boost::end(rng), dest, std::forward<F>(f), std::forward<Proj>(proj)); }
void UserQueue::getUserQIs(const UserPtr& aUser, QueueItemList& ql) noexcept{ /* Returns all queued items from an user */ /* Highest prio */ auto i = userPrioQueue.find(aUser); if(i != userPrioQueue.end()) { dcassert(!i->second.empty()); copy_if(i->second.begin(), i->second.end(), back_inserter(ql), [](const QueueItemPtr& q) { return !q->getBundle(); }); //bundle items will be added from the bundle queue } /* Bundles */ auto s = userBundleQueue.find(aUser); if(s != userBundleQueue.end()) { dcassert(!s->second.empty()); for(auto& b: s->second) b->getItems(aUser, ql); } }
//Function to split string based on regex and put in list. Default predicate is just non-emptiness void splitString(std::string& source, std::string splitRegex, std::list<std::string>& stringList, std::function<bool(std::string)> predicate){ std::regex split(splitRegex); copy_if(std::sregex_token_iterator(source.begin(), source.end(), split, -1), std::sregex_token_iterator(),back_inserter(stringList), predicate); }
int main() { std::ifstream input { "/usr/share/dict/words" }; using initer=std::istream_iterator<std::string>; std::ostream_iterator<std::string> out { std::cout, "\n" }; copy_if(initer { input }, initer { }, out, isPalindrome); }
static void TestAlgorithms (void) { static const int c_TestNumbers[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16, 17, 18 }; const int* first = c_TestNumbers; const int* last = first + VectorSize(c_TestNumbers); intvec_t v, buf; v.assign (first, last); PrintVector (v); cout << "swap(1,2)\n"; swap (v[0], v[1]); PrintVector (v); v.assign (first, last); cout << "copy(0,8,9)\n"; copy (v.begin(), v.begin() + 8, v.begin() + 9); PrintVector (v); v.assign (first, last); cout << "copy with back_inserter\n"; v.clear(); copy (first, last, back_inserter(v)); PrintVector (v); v.assign (first, last); cout << "copy with inserter\n"; v.clear(); copy (first, first + 5, inserter(v, v.begin())); copy (first, first + 5, inserter(v, v.begin() + 3)); PrintVector (v); v.assign (first, last); cout << "copy_n(0,8,9)\n"; copy_n (v.begin(), 8, v.begin() + 9); PrintVector (v); v.assign (first, last); cout << "copy_if(is_even)\n"; intvec_t v_even; copy_if (v, back_inserter(v_even), &is_even); PrintVector (v_even); v.assign (first, last); cout << "for_each(printint)\n{ "; for_each (v, &printint); cout << "}\n"; cout << "for_each(reverse_iterator, printint)\n{ "; for_each (v.rbegin(), v.rend(), &printint); cout << "}\n"; cout << "find(10)\n"; cout.format ("10 found at offset %zd\n", abs_distance (v.begin(), find (v, 10))); cout << "count(13)\n"; cout.format ("%zu values of 13, %zu values of 18\n", count(v,13), count(v,18)); cout << "transform(sqr)\n"; transform (v, &sqr); PrintVector (v); v.assign (first, last); cout << "replace(13,666)\n"; replace (v, 13, 666); PrintVector (v); v.assign (first, last); cout << "fill(13)\n"; fill (v, 13); PrintVector (v); v.assign (first, last); cout << "fill_n(5, 13)\n"; fill_n (v.begin(), 5, 13); PrintVector (v); v.assign (first, last); cout << "fill 64083 uint8_t(0x41) "; TestBigFill<uint8_t> (64083, 0x41); cout << "fill 64083 uint16_t(0x4142) "; TestBigFill<uint16_t> (64083, 0x4142); cout << "fill 64083 uint32_t(0x41424344) "; TestBigFill<uint32_t> (64083, 0x41424344); cout << "fill 64083 float(0.4242) "; TestBigFill<float> (64083, 0x4242f); #if HAVE_INT64_T cout << "fill 64083 uint64_t(0x4142434445464748) "; TestBigFill<uint64_t> (64083, UINT64_C(0x4142434445464748)); #else cout << "No 64bit types available on this platform\n"; #endif cout << "copy 64083 uint8_t(0x41) "; TestBigCopy<uint8_t> (64083, 0x41); cout << "copy 64083 uint16_t(0x4142) "; TestBigCopy<uint16_t> (64083, 0x4142); cout << "copy 64083 uint32_t(0x41424344) "; TestBigCopy<uint32_t> (64083, 0x41424344); cout << "copy 64083 float(0.4242) "; TestBigCopy<float> (64083, 0.4242f); #if HAVE_INT64_T cout << "copy 64083 uint64_t(0x4142434445464748) "; TestBigCopy<uint64_t> (64083, UINT64_C(0x4142434445464748)); #else cout << "No 64bit types available on this platform\n"; #endif cout << "generate(genint)\n"; generate (v, &genint); PrintVector (v); v.assign (first, last); cout << "rotate(4)\n"; rotate (v, 7); rotate (v, -3); PrintVector (v); v.assign (first, last); cout << "merge with (3,5,10,11,11,14)\n"; const int c_MergeWith[] = { 3,5,10,11,11,14 }; intvec_t vmerged; merge (v.begin(), v.end(), VectorRange(c_MergeWith), back_inserter(vmerged)); PrintVector (vmerged); v.assign (first, last); cout << "inplace_merge with (3,5,10,11,11,14)\n"; v.insert (v.end(), VectorRange(c_MergeWith)); inplace_merge (v.begin(), v.end() - VectorSize(c_MergeWith), v.end()); PrintVector (v); v.assign (first, last); cout << "remove(13)\n"; remove (v, 13); PrintVector (v); v.assign (first, last); cout << "remove (elements 3, 4, 6, 15, and 45)\n"; vector<uoff_t> toRemove; toRemove.push_back (3); toRemove.push_back (4); toRemove.push_back (6); toRemove.push_back (15); toRemove.push_back (45); typedef index_iterate<intvec_t::iterator, vector<uoff_t>::iterator> riiter_t; riiter_t rfirst = index_iterator (v.begin(), toRemove.begin()); riiter_t rlast = index_iterator (v.begin(), toRemove.end()); remove (v, rfirst, rlast); PrintVector (v); v.assign (first, last); cout << "unique\n"; unique (v); PrintVector (v); v.assign (first, last); cout << "reverse\n"; reverse (v); PrintVector (v); v.assign (first, last); cout << "lower_bound(10)\n"; PrintVector (v); cout.format ("10 begins at position %zd\n", abs_distance (v.begin(), lower_bound (v, 10))); v.assign (first, last); cout << "upper_bound(10)\n"; PrintVector (v); cout.format ("10 ends at position %zd\n", abs_distance (v.begin(), upper_bound (v, 10))); v.assign (first, last); cout << "equal_range(10)\n"; PrintVector (v); TestEqualRange (v); v.assign (first, last); cout << "sort\n"; reverse (v); PrintVector (v); random_shuffle (v); sort (v); PrintVector (v); v.assign (first, last); cout << "stable_sort\n"; reverse (v); PrintVector (v); random_shuffle (v); stable_sort (v); PrintVector (v); v.assign (first, last); cout << "is_sorted\n"; random_shuffle (v); const bool bNotSorted = is_sorted (v.begin(), v.end()); sort (v); const bool bSorted = is_sorted (v.begin(), v.end()); cout << "unsorted=" << bNotSorted << ", sorted=" << bSorted << endl; v.assign (first, last); cout << "find_first_of\n"; static const int c_FFO[] = { 10000, -34, 14, 27 }; cout.format ("found 14 at position %zd\n", abs_distance (v.begin(), find_first_of (v.begin(), v.end(), VectorRange(c_FFO)))); v.assign (first, last); static const int LC1[] = { 3, 1, 4, 1, 5, 9, 3 }; static const int LC2[] = { 3, 1, 4, 2, 8, 5, 7 }; static const int LC3[] = { 1, 2, 3, 4 }; static const int LC4[] = { 1, 2, 3, 4, 5 }; cout << "lexicographical_compare"; cout << "\nLC1 < LC2 == " << lexicographical_compare (VectorRange(LC1), VectorRange(LC2)); cout << "\nLC2 < LC2 == " << lexicographical_compare (VectorRange(LC2), VectorRange(LC2)); cout << "\nLC3 < LC4 == " << lexicographical_compare (VectorRange(LC3), VectorRange(LC4)); cout << "\nLC4 < LC1 == " << lexicographical_compare (VectorRange(LC4), VectorRange(LC1)); cout << "\nLC1 < LC4 == " << lexicographical_compare (VectorRange(LC1), VectorRange(LC4)); cout << "\nmax_element\n"; cout.format ("max element is %d\n", *max_element (v.begin(), v.end())); v.assign (first, last); cout << "min_element\n"; cout.format ("min element is %d\n", *min_element (v.begin(), v.end())); v.assign (first, last); cout << "partial_sort\n"; reverse (v); partial_sort (v.begin(), v.iat(v.size() / 2), v.end()); PrintVector (v); v.assign (first, last); cout << "partial_sort_copy\n"; reverse (v); buf.resize (v.size()); partial_sort_copy (v.begin(), v.end(), buf.begin(), buf.end()); PrintVector (buf); v.assign (first, last); cout << "partition\n"; partition (v.begin(), v.end(), &is_even); PrintVector (v); v.assign (first, last); cout << "stable_partition\n"; stable_partition (v.begin(), v.end(), &is_even); PrintVector (v); v.assign (first, last); cout << "next_permutation\n"; buf.resize (3); iota (buf.begin(), buf.end(), 1); PrintVector (buf); while (next_permutation (buf.begin(), buf.end())) PrintVector (buf); cout << "prev_permutation\n"; reverse (buf); PrintVector (buf); while (prev_permutation (buf.begin(), buf.end())) PrintVector (buf); v.assign (first, last); cout << "reverse_copy\n"; buf.resize (v.size()); reverse_copy (v.begin(), v.end(), buf.begin()); PrintVector (buf); v.assign (first, last); cout << "rotate_copy\n"; buf.resize (v.size()); rotate_copy (v.begin(), v.iat (v.size() / 3), v.end(), buf.begin()); PrintVector (buf); v.assign (first, last); static const int c_Search1[] = { 5, 6, 7, 8, 9 }, c_Search2[] = { 10, 10, 11, 14 }; cout << "search\n"; cout.format ("{5,6,7,8,9} at %zd\n", abs_distance (v.begin(), search (v.begin(), v.end(), VectorRange(c_Search1)))); cout.format ("{10,10,11,14} at %zd\n", abs_distance (v.begin(), search (v.begin(), v.end(), VectorRange(c_Search2)))); cout << "find_end\n"; cout.format ("{5,6,7,8,9} at %zd\n", abs_distance (v.begin(), find_end (v.begin(), v.end(), VectorRange(c_Search1)))); cout.format ("{10,10,11,14} at %zd\n", abs_distance (v.begin(), find_end (v.begin(), v.end(), VectorRange(c_Search2)))); cout << "search_n\n"; cout.format ("{14} at %zd\n", abs_distance (v.begin(), search_n (v.begin(), v.end(), 1, 14))); cout.format ("{13,13} at %zd\n", abs_distance (v.begin(), search_n (v.begin(), v.end(), 2, 13))); cout.format ("{10,10,10} at %zd\n", abs_distance (v.begin(), search_n (v.begin(), v.end(), 3, 10))); v.assign (first, last); cout << "includes\n"; static const int c_Includes[] = { 5, 14, 15, 18, 20 }; cout << "includes=" << includes (v.begin(), v.end(), VectorRange(c_Includes)-1); cout << ", not includes=" << includes (v.begin(), v.end(), VectorRange(c_Includes)); cout << endl; static const int c_Set1[] = { 1, 2, 3, 4, 5, 6 }, c_Set2[] = { 4, 4, 6, 7, 8 }; intvec_t::iterator setEnd; cout << "set_difference\n"; v.resize (4); setEnd = set_difference (VectorRange(c_Set1), VectorRange(c_Set2), v.begin()); PrintVector (v); assert (setEnd == v.end()); cout << "set_symmetric_difference\n"; v.resize (7); setEnd = set_symmetric_difference (VectorRange(c_Set1), VectorRange(c_Set2), v.begin()); PrintVector (v); assert (setEnd == v.end()); cout << "set_intersection\n"; v.resize (2); setEnd = set_intersection (VectorRange(c_Set1), VectorRange(c_Set2), v.begin()); PrintVector (v); assert (setEnd == v.end()); cout << "set_union\n"; v.resize (9); setEnd = set_union (VectorRange(c_Set1), VectorRange(c_Set2), v.begin()); PrintVector (v); assert (setEnd == v.end()); v.assign (first, last); }
int Battle::process_situation() { // Checking whether party is dead: auto iterator1 = find_if((party_in_battle->creatures).begin(), (party_in_battle->creatures).end(), [](Unit x){ return x.is_dead() == false;}); if(iterator1 == (party_in_battle->creatures).end()) return 0; // Checking whether enemies are dead: auto iterator2 = find_if((opponents_in_battle->creatures).begin(), (opponents_in_battle->creatures).end(), [](Unit x){ return x.is_dead() == false;}); if(iterator2 == (opponents_in_battle->creatures).end()) return 2; // Still fighting: while(battle_queue.empty()) { // Increasing current initiative for every unit: for_each((party_in_battle->creatures).begin(), (party_in_battle->creatures).end(), [](Unit x){ x.modify_current_initiative(x.initiative); }); for_each((opponents_in_battle->creatures).begin(), (opponents_in_battle->creatures).end(), [](Unit x){ x.modify_current_initiative(x.initiative); }); vector <Hero> temp_heroes; // List of heroes that are ready to act in combat vector <Unit> temp_enemies; // List of enemies that are ready to act in combat // Making lists of units that are ready to act in combat: copy_if((party_in_battle->creatures).begin(), (party_in_battle->creatures).end(), temp_heroes.begin(), [](Unit x) { if(x.get_current_initiative() >= INITIATIVE_CONSTANT) { x.modify_current_initiative((-1)*x.initiative); return true; } return false; }); copy_if((opponents_in_battle->creatures).begin(), (opponents_in_battle->creatures).end(), temp_enemies.begin(), [](Unit x) { if(x.get_current_initiative() >= INITIATIVE_CONSTANT) { x.modify_current_initiative((-1)*x.initiative); return true; } return false; }); // Sorting lists of units that are ready to act in combat: sort(temp_heroes.begin(), temp_heroes.end(), [](Unit x, Unit y){return x.get_current_initiative() < y.get_current_initiative();}); sort(temp_enemies.begin(), temp_enemies.end(), [](Unit x, Unit y){return x.get_current_initiative() < y.get_current_initiative();}); auto iterator3 = temp_heroes.begin(); auto iterator4 = temp_enemies.begin(); // Merging two sorted lists into one battle queue: while(iterator3 != temp_heroes.end() || iterator4 != temp_enemies.end()) { if(iterator3->get_current_initiative() > iterator4->get_current_initiative()) { battle_queue.push(&(*iterator3)); ++iterator3; } else { battle_queue.push(&(*iterator4)); ++iterator4; } } if(iterator3 == temp_heroes.end()) while(iterator4 != temp_enemies.end()) { battle_queue.push(&(*iterator4)); ++iterator4; } else while(iterator3 != temp_heroes.end()) { battle_queue.push(&(*iterator3)); ++iterator3; } } return 1; }
void get_x_length_words(const vector<string>& wtypes, int x, vector<string>& words) { copy_if(wtypes.begin(), wtypes.end(), back_inserter(words), [x = string::size_type(x)](string s) {return s.length() >= x;}); }