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 an empty table.

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

Constructs an 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 a table containing copies of elements in the iterator half-open interval [first,last).

concurrent_hash_map( 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(concurrent_hash_map&& source)

C++11 specific; Constructs a new table by moving content from the source table. source is left in an unspecified state, but can be safely destroyed.

concurrent_hash_map(concurrent_hash_map&& source, const allocator_type& a)

C++11 specific; Constructs a new table by moving content from the source table using specified allocator. source is left in an unspecified state, but can be safely destroyed.

~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: a reference to *this.

concurrent_hash_map& operator=(concurrent_hash_map&& source);

C++11 specific; Moves data from the source table to *this. source is left in an unspecified state, but can be safely destroyed.

Returns: a reference to *this.

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

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

Returns: a reference to *this.

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. The rehash method reorganizes 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: a copy of allocator used to construct table.

For more complete information about compiler optimizations, see our Optimization Notice.