...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::interprocess::iunordered_set_index
// In header: <boost/interprocess/indexes/iunordered_set_index.hpp> template<typename MapConfig> class iunordered_set_index : private boost::interprocess::iunordered_set_index_aux< MapConfig >::allocator_holder { public: // types typedef index_type::iterator iterator; typedef index_type::const_iterator const_iterator; typedef index_type::insert_commit_data insert_commit_data; typedef index_type::value_type value_type; typedef index_type::bucket_ptr bucket_ptr; typedef index_type::bucket_type bucket_type; typedef index_type::bucket_traits bucket_traits; typedef index_type::size_type size_type; typedef index_aux::segment_manager_base segment_manager_base; // @ private: enum @4 { InitBufferSize = 64 }; // construct/copy/destruct iunordered_set_index(segment_manager_base *); ~iunordered_set_index(); // public static functions static bucket_ptr create_buckets(allocator_type &, std::size_t); static std::size_t shrink_buckets(bucket_ptr, std::size_t, allocator_type &, std::size_t); static bucket_ptr expand_or_create_buckets(bucket_ptr, const std::size_t, allocator_type &, const std::size_t); static void destroy_buckets(allocator_type &, bucket_ptr, std::size_t); // public member functions iunordered_set_index< MapConfig > * get_this_pointer(); void reserve(std::size_t); void shrink_to_fit(); iterator find(const intrusive_compare_key_type &); const_iterator find(const intrusive_compare_key_type &) const; std::pair< iterator, bool > insert_check(const intrusive_compare_key_type &, insert_commit_data &); iterator insert_commit(value_type &, insert_commit_data &); };
Index type based in boost::intrusive::set. Just derives from boost::intrusive::set and defines the interface needed by managed memory segments
iunordered_set_index
public static functionsstatic bucket_ptr create_buckets(allocator_type & alloc, std::size_t num);
static std::size_t shrink_buckets(bucket_ptr buckets, std::size_t old_size, allocator_type & alloc, std::size_t new_size);
static bucket_ptr expand_or_create_buckets(bucket_ptr old_buckets, const std::size_t old_num, allocator_type & alloc, const std::size_t new_num);
static void destroy_buckets(allocator_type & alloc, bucket_ptr buckets, std::size_t num);
iunordered_set_index
public member functionsiunordered_set_index< MapConfig > * get_this_pointer();
void reserve(std::size_t new_n);
This reserves memory to optimize the insertion of n elements in the index
void shrink_to_fit();
This tries to free unused memory previously allocated.
iterator find(const intrusive_compare_key_type & key);
const_iterator find(const intrusive_compare_key_type & key) const;
std::pair< iterator, bool > insert_check(const intrusive_compare_key_type & key, insert_commit_data & commit_data);
iterator insert_commit(value_type & val, insert_commit_data & commit_data);