Unordered map from Key to T. More...
#include <concurrent_hash_map.h>
Classes | |
class | accessor |
Allows write access to elements and combines data access, locking, and garbage collection. More... | |
class | bucket_accessor |
bucket accessor is to find, rehash, acquire a lock, and access a bucket More... | |
class | const_accessor |
Combines data access, locking, and garbage collection. More... | |
struct | node |
Public Types | |
typedef Key | key_type |
typedef T | mapped_type |
typedef std::pair< const Key, T > | value_type |
typedef hash_map_base::size_type | size_type |
typedef ptrdiff_t | difference_type |
typedef value_type * | pointer |
typedef const value_type * | const_pointer |
typedef value_type & | reference |
typedef const value_type & | const_reference |
typedef internal::hash_map_iterator < concurrent_hash_map, value_type > | iterator |
typedef internal::hash_map_iterator < concurrent_hash_map, const value_type > | const_iterator |
typedef internal::hash_map_range < iterator > | range_type |
typedef internal::hash_map_range < const_iterator > | const_range_type |
typedef Allocator | allocator_type |
Public Member Functions | |
concurrent_hash_map (const allocator_type &a=allocator_type()) | |
Construct empty table. | |
concurrent_hash_map (size_type n, const allocator_type &a=allocator_type()) | |
Construct empty table with n preallocated buckets. This number serves also as initial concurrency level. | |
concurrent_hash_map (const concurrent_hash_map &table, const allocator_type &a=allocator_type()) | |
Copy constructor. | |
template<typename I > | |
concurrent_hash_map (I first, I last, const allocator_type &a=allocator_type()) | |
Construction with copying iteration range and given allocator instance. | |
concurrent_hash_map (const std::initializer_list< value_type > &il, const allocator_type &a=allocator_type()) | |
Construct empty table with n preallocated buckets. This number serves also as initial concurrency level. | |
concurrent_hash_map & | operator= (const concurrent_hash_map &table) |
Assignment. | |
concurrent_hash_map & | operator= (const std::initializer_list< value_type > &il) |
Assignment. | |
void | rehash (size_type n=0) |
Rehashes and optionally resizes the whole table. More... | |
void | clear () |
Clear table. | |
~concurrent_hash_map () | |
Clear table and destroy it. | |
range_type | range (size_type grainsize=1) |
const_range_type | range (size_type grainsize=1) const |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
std::pair< iterator, iterator > | equal_range (const Key &key) |
std::pair< const_iterator, const_iterator > | equal_range (const Key &key) const |
size_type | size () const |
Number of items in table. | |
bool | empty () const |
True if size()==0. | |
size_type | max_size () const |
Upper bound on size. | |
size_type | bucket_count () const |
Returns the current number of buckets. | |
allocator_type | get_allocator () const |
return allocator object | |
void | swap (concurrent_hash_map &table) |
swap two instances. Iterators are invalidated | |
size_type | count (const Key &key) const |
Return count of items (0 or 1) | |
bool | find (const_accessor &result, const Key &key) const |
Find item and acquire a read lock on the item. More... | |
bool | find (accessor &result, const Key &key) |
Find item and acquire a write lock on the item. More... | |
bool | insert (const_accessor &result, const Key &key) |
Insert item (if not already present) and acquire a read lock on the item. More... | |
bool | insert (accessor &result, const Key &key) |
Insert item (if not already present) and acquire a write lock on the item. More... | |
bool | insert (const_accessor &result, const value_type &value) |
Insert item by copying if there is no such key present already and acquire a read lock on the item. More... | |
bool | insert (accessor &result, const value_type &value) |
Insert item by copying if there is no such key present already and acquire a write lock on the item. More... | |
bool | insert (const value_type &value) |
Insert item by copying if there is no such key present already. More... | |
template<typename I > | |
void | insert (I first, I last) |
Insert range [first, last) | |
bool | erase (const Key &key) |
Erase item. More... | |
bool | erase (const_accessor &item_accessor) |
Erase item by const_accessor. More... | |
bool | erase (accessor &item_accessor) |
Erase item by accessor. More... | |
Protected Types | |
typedef Allocator::template rebind< node >::other | node_allocator_type |
Protected Member Functions | |
void | delete_node (node_base *n) |
node * | search_bucket (const key_type &key, bucket *b) const |
void | rehash_bucket (bucket *b_new, const hashcode_t h) |
bool | lookup (bool op_insert, const Key &key, const T *t, const_accessor *result, bool write) |
Insert or find item and optionally acquire a lock on the item. | |
bool | exclude (const_accessor &item_accessor) |
delete item by accessor | |
template<typename I > | |
std::pair< I, I > | internal_equal_range (const Key &key, I end) const |
Returns an iterator for an item defined by the key, or for the next item after it (if upper==true) | |
void | internal_copy (const concurrent_hash_map &source) |
Copy "source" to *this, where *this must start out empty. | |
template<typename I > | |
void | internal_copy (I first, I last) |
const_pointer | internal_fast_find (const Key &key) const |
Fast find when no concurrent erasure is used. For internal use inside TBB only! More... | |
Protected Attributes | |
node_allocator_type | my_allocator |
HashCompare | my_hash_compare |
Friends | |
template<typename Container , typename Value > | |
class | internal::hash_map_iterator |
template<typename I > | |
class | internal::hash_map_range |
class | const_accessor |
Unordered map from Key to T.
concurrent_hash_map is associative container with concurrent access.
bool tbb::interface5::concurrent_hash_map< Key, T, HashCompare, A >::erase | ( | const Key & | key) |
Erase item.
Return true if item was erased by particularly this call.
References tbb::interface5::concurrent_hash_map< Key, T, HashCompare, A >::bucket_accessor::is_writer().
|
inline |
Erase item by const_accessor.
Return true if item was erased by particularly this call.
|
inline |
Erase item by accessor.
Return true if item was erased by particularly this call.
|
inline |
Find item and acquire a read lock on the item.
Return true if item is found, false otherwise.
References tbb::interface5::concurrent_hash_map< Key, T, HashCompare, A >::const_accessor::release().
|
inline |
Find item and acquire a write lock on the item.
Return true if item is found, false otherwise.
References tbb::interface5::concurrent_hash_map< Key, T, HashCompare, A >::const_accessor::release().
|
inline |
Insert item (if not already present) and acquire a read lock on the item.
Returns true if item is new.
References tbb::interface5::concurrent_hash_map< Key, T, HashCompare, A >::const_accessor::release().
|
inline |
Insert item (if not already present) and acquire a write lock on the item.
Returns true if item is new.
References tbb::interface5::concurrent_hash_map< Key, T, HashCompare, A >::const_accessor::release().
|
inline |
Insert item by copying if there is no such key present already and acquire a read lock on the item.
Returns true if item is new.
References tbb::interface5::concurrent_hash_map< Key, T, HashCompare, A >::const_accessor::release().
|
inline |
Insert item by copying if there is no such key present already and acquire a write lock on the item.
Returns true if item is new.
References tbb::interface5::concurrent_hash_map< Key, T, HashCompare, A >::const_accessor::release().
|
inline |
Insert item by copying if there is no such key present already.
Returns true if item is inserted.
|
inlineprotected |
Fast find when no concurrent erasure is used. For internal use inside TBB only!
Return pointer to item with given key, or NULL if no such item exists. Must not be called concurrently with erasure operations.
void tbb::interface5::concurrent_hash_map< Key, T, HashCompare, A >::rehash | ( | size_type | n = 0 ) |