Whole Table Operations

These operations affect an entire table. Do not concurrently invoke them on the same table.

The following table provides additional information on the members of this template class.
Member Description
concurrent_hash_map( const allocator_type& a = allocator_type()  )

Constructs empty table.

concurrent_hash_map( size_type n, const allocator_type& a = allocator_type() )

Constructs empty table with preallocated buckets for at least n items.

Note

In general, thread contention for buckets is inversely related to the number of buckets. If memory consumption is not an issue and P threads will be accessing the concurrent_hash_map, set n>=4P.

concurrent_hash_map( const concurrent_hash_map& table, const allocator_type& a = allocator_type() )

Copies a table. The table being copied may have const operations running on it concurrently.

template<typename  InputIterator> concurrent_hash_map( InputIterator first, InputIterator last,  const allocator_type& a = allocator_type() )

Constructs table containing copies of elements in the iterator half-open interval [first,last).

concurrent_hash_map( const std::initializer_list<value_type> &il , const allocator_type &a = allocator_type() )

C++11 specific; Equivalent to concurrent_hash_map(il.begin(), il.end(), a).

~concurrent_hash_map()

Invokes clear(). This method is not safe to execute concurrently with other methods on the same concurrent_hash_map.

concurrent_hash_map& operator= ( concurrent_hash_map& source )

If source and destination (this) table are distinct, clears the destination table and copies all key-value pairs from the source table to the destination table. Otherwise, does nothing.

Returns

Reference to the destination table.

concurrent_hash_map& operator= ( const std::initializer_list<value_type> &il )

C++11 specific; Sets *this to contain data from il.

Returns

Reference to the destination table.

void swap( concurrent_hash_map& table )

Swaps contents and allocators of this and table.

void rehash( size_type n=0 )

Internally, the table is partitioned into buckets. Method rehash reorgnizes these internal buckets in a way that may improve performance of future lookups. Raises number of internal buckets to n if n>0 and n exceeds the current number of buckets.

Caution

The current implementation never reduces the number of buckets. A future implementation might reduce the number of buckets if n is less than the current number of buckets.

Note

The ratio of items to buckets affects time and space usage by a table. A high ratio saves space at the expense of time. A low ratio does the opposite. The default ratio is 0.5 to 1 items per bucket on average.

void clear()

Erases all key-value pairs from the table. Does not hash or compare any keys.

If TBB_USE_PERFORMANCE_WARNINGS is nonzero, issues a performance warning if the randomness of the hashing is poor enough to significantly impact performance.

allocator_type get_allocator() const

Returns: Copy of allocator used to construct table.