コード例 #1
0
int main() {
    std::cout << "Element size: " << sizeof(map_element) << std::endl;

    std::cout << "std::map: ";
    run_tests(packet_collector_thread_std_map);
    DataCounter.clear();

#ifndef __APPLE__
    std::cout << "tbb::concurrent_unordered_map: ";
    run_tests(packet_collector_thread_unordered_concurrent_map);
    DataCounterUnorderedConcurrent.clear();
#endif

    // Boost unordered map
    std::cout << "boost::unordered_map: ";
    run_tests(packet_collector_thread_boost_unordered_map);
    DataCounterBoostUnordered.clear();

    // Boost flat_map
    DataCounterBoostFlatMap.reserve( number_of_ips );
    std::cout << "boost::container::flat_map with preallocated elements: ";
    run_tests(packet_collector_thread_flat_map_preallocated);
    DataCounterBoostFlatMap.clear();

    std::cout << "std::unordered_map C++11: ";
    run_tests(packet_collector_thread_unordered_map);
    DataCounterUnordered.clear();

    // Preallocate hash buckets
    DataCounterUnorderedPreallocated.reserve( number_of_ips );
    std::cout << "std::unordered_map C++11 preallocated buckets: ";
    run_tests(packet_collector_thread_unordered_map_preallocated);
    DataCounterUnorderedPreallocated.clear();

    // Preallocate vector
    DataCounterVector.reserve( number_of_ips );
    std::cout << "std::vector preallocated: ";
    run_tests(packet_collector_thread_vector);
    DataCounterVector.clear();
}
コード例 #2
0
ファイル: workflow_system.cpp プロジェクト: thebracket/bgame
void workflow_system::update(const double duration_ms) {
    if (dirty) {
        automatic_reactions.clear();

        // Enumerate buildings and see which ones have reactions.
        each<position_t, building_t>([this] (entity_t &e, position_t &pos, building_t &b) {
            if (b.complete) {
                auto finder = reaction_building_defs.find(b.tag);
                if (finder != reaction_building_defs.end()) {
                    for (const std::string &reaction_name : finder->second) {
                        auto reactor = reaction_defs.find(reaction_name);
                        if (reactor != reaction_defs.end()) {

                            // Automatic reactions are added to the auto reactor list
                            if (reactor->second.automatic) {
                                auto automatic_finder = automatic_reactions.find(e.id);
                                if (automatic_finder == automatic_reactions.end()) {
                                    automatic_reactions[e.id] = std::vector<std::string>{ reaction_name };
                                } else {
                                    automatic_finder->second.push_back(reaction_name);
                                }
                            }
                        }
                    }
                }
            }
        });

        // Erase all completed jobs
        designations->build_orders.erase(
            std::remove_if(designations->build_orders.begin(),
                designations->build_orders.end(),
                [] (auto order_pair) { return order_pair.first == 0; }),
            designations->build_orders.end());

        // Not dirty anymore!
        dirty = false;
    }
}
コード例 #3
0
void UnregisterFileSystems() {
    filesystem_map.clear();
}
コード例 #4
0
ファイル: archive.cpp プロジェクト: FenrisulfrX/citra
void UnregisterArchiveTypes() {
    id_code_map.clear();
}