void test_algorithm::test_erase_if() { QList<int> l1; l1 << 1 << 2 << 3 << 4; erase_if(l1, [](int i) { return i > 2; }); QCOMPARE(l1, (QList<int>{} << 1 << 2)); erase_if(l1, [](int i) { return i > 0; }); QCOMPARE(l1, QList<int>{}); erase_if(l1, [](int i) { return i > 0; }); QCOMPARE(l1, QList<int>{}); }
void fae_tree_filter::perform( const cosmos& cosm, std::unordered_set<entity_id>& selections ) const { if (!any()) { return; } erase_if( selections, [&](const entity_id id) { if (deselect_type_id) { return id.type_id == *deselect_type_id; } if (deselect_flavour_id) { return cosm[id].get_flavour_id() == *deselect_flavour_id; } if (select_only_type_id) { return id.type_id != *select_only_type_id; } if (select_only_flavour_id) { return cosm[id].get_flavour_id() != *select_only_flavour_id; } return true; } ); }
bool invoke(Policy& policy, Client* client, mailbox_element* node) { CPPA_REQUIRE(!empty()); CPPA_REQUIRE(client != nullptr); CPPA_REQUIRE(node != nullptr); // use a copy of bhvr, because invoked behavior might change m_elements auto id = m_elements.back().second; auto bhvr = m_elements.back().first; if (policy.invoke(client, node, bhvr, id)) { bool repeat; // try to match cached messages do { // remove synchronous response handler if needed if (id.valid()) { erase_if([id](const element_type& value) { return id == value.second; }); } if (!empty()) { id = m_elements.back().second; bhvr = m_elements.back().first; repeat = policy.invoke_from_cache(client, bhvr, id); } else repeat = false; } while (repeat); return true; } return false; }
void flying_number_indicator_system::advance(const augs::delta dt) { global_time_seconds += dt.in_seconds(); erase_if( numbers, [this](const number& n) { const auto passed_time_seconds = global_time_seconds - n.time_of_occurence_seconds; return passed_time_seconds > n.in.maximum_duration_seconds; } ); }
void KnightRiderExplosionTest::update(f32 timeSinceLastFrame) { erase_if(all, boost::bind(&Effect::done, _1)); static f32 time = 0.0f; time += timeSinceLastFrame; static f32 x = 0.0f; if (time > 0.1f) { x += 0.5f; boost::shared_ptr<ExpT> e(new Explosion2(v3(cos(x) * 100.0f, 0.0f, 200.0f), 1.0f)); all.push_back(e); time = 0.0f; } }
void remove_unreferenced_entity(Entity& entity) { assert(!is_referenced(entity)); for (auto& referenced_entity : m_outgoing_refs[&entity]) { // Remove references from referenced entities toward this entity. IncomingRefVec& incoming_refs = m_incoming_refs[referenced_entity.m_entity]; erase_if( incoming_refs, [&entity](const IncomingRef& ref) { return ref.m_entity == &entity; }); if (incoming_refs.empty()) m_incoming_refs.erase(referenced_entity.m_entity); if (!is_referenced(*referenced_entity.m_entity)) { RENDERER_LOG_DEBUG("entity " FMT_ENTITY " is not referenced and will be removed.", referenced_entity.m_entity->get_path().c_str(), referenced_entity.m_entity->get_uid()); remove_unreferenced_entity(*referenced_entity.m_entity); RENDERER_LOG_DEBUG("removing entity " FMT_ENTITY "...", referenced_entity.m_entity->get_path().c_str(), referenced_entity.m_entity->get_uid()); assert(referenced_entity.m_map || referenced_entity.m_vector); if (referenced_entity.m_map != nullptr) referenced_entity.m_map->remove(referenced_entity.m_entity); else referenced_entity.m_vector->remove(referenced_entity.m_entity); } } // Remove references from this entity toward other entities. m_outgoing_refs.erase(&entity); }
void erase_if(Container &container, Predicate pred) { erase_if(container, container.begin(), container.end(), pred); }
// erases the synchronous response handler associated with @p rid void erase(message_id rid) { erase_if([=](const element_type& e) { return e.second == rid; }); }
bool ViewMainState::frameStarted(const Ogre::FrameEvent& evt) { erase_if(mEffects, boost::bind(&View::Effect::done, _1)); return true; }