本文整理汇总了C++中boost::container::flat_map::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ flat_map::reserve方法的具体用法?C++ flat_map::reserve怎么用?C++ flat_map::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::container::flat_map
的用法示例。
在下文中一共展示了flat_map::reserve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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();
}