tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator > Class Template Reference
[Containers]

Unordered map from Key to T. More...

#include <concurrent_hash_map.h>

List of all members.

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_mapoperator= (const concurrent_hash_map &table)
 Assignment.
void rehash (size_type n=0)
 Rehashes and optionally resizes the whole table.
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.
bool find (accessor &result, const Key &key)
 Find item and acquire a write lock on the item.
bool insert (const_accessor &result, const Key &key)
 Insert item (if not already present) and acquire a read lock on the item.
bool insert (accessor &result, const Key &key)
 Insert item (if not already present) and acquire a write lock on the item.
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.
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.
bool insert (const value_type &value)
 Insert item by copying if there is no such key present already.
template<typename I>
void insert (I first, I last)
 Insert range [first, last).
bool erase (const Key &key)
 Erase item.
bool erase (const_accessor &item_accessor)
 Erase item by const_accessor.
bool erase (accessor &item_accessor)
 Erase item by accessor.

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!

Protected Attributes

node_allocator_type my_allocator
HashCompare my_hash_compare

Friends

class internal::hash_map_iterator
class internal::hash_map_range
class const_accessor

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


Detailed Description

template<typename Key, typename T, typename HashCompare, typename Allocator>
class tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >

Unordered map from Key to T.

concurrent_hash_map is associative container with concurrent access.

Compatibility
The class meets all Container Requirements from C++ Standard (See ISO/IEC 14882:2003(E), clause 23.1).
Exception Safety
Changes since TBB 2.1
Changes since TBB 2.0


Member Function Documentation

template<typename Key, typename T, typename HashCompare, typename Allocator>
bool tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >::erase ( accessor item_accessor  )  [inline]

Erase item by accessor.

Return true if item was erased by particularly this call.

template<typename Key, typename T, typename HashCompare, typename Allocator>
bool tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >::erase ( const_accessor item_accessor  )  [inline]

Erase item by const_accessor.

Return true if item was erased by particularly this call.

template<typename Key, typename T, typename HashCompare, typename A>
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.

template<typename Key, typename T, typename HashCompare, typename Allocator>
bool tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >::find ( accessor result,
const Key &  key 
) [inline]

Find item and acquire a write lock on the item.

Return true if item is found, false otherwise.

template<typename Key, typename T, typename HashCompare, typename Allocator>
bool tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >::find ( const_accessor result,
const Key &  key 
) const [inline]

Find item and acquire a read lock on the item.

Return true if item is found, false otherwise.

template<typename Key, typename T, typename HashCompare, typename Allocator>
bool tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >::insert ( const value_type &  value  )  [inline]

Insert item by copying if there is no such key present already.

Returns true if item is inserted.

template<typename Key, typename T, typename HashCompare, typename Allocator>
bool tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >::insert ( accessor result,
const value_type &  value 
) [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.

template<typename Key, typename T, typename HashCompare, typename Allocator>
bool tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >::insert ( const_accessor result,
const value_type &  value 
) [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.

template<typename Key, typename T, typename HashCompare, typename Allocator>
bool tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >::insert ( accessor result,
const Key &  key 
) [inline]

Insert item (if not already present) and acquire a write lock on the item.

Returns true if item is new.

template<typename Key, typename T, typename HashCompare, typename Allocator>
bool tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >::insert ( const_accessor result,
const Key &  key 
) [inline]

Insert item (if not already present) and acquire a read lock on the item.

Returns true if item is new.

template<typename Key, typename T, typename HashCompare, typename Allocator>
const_pointer tbb::interface5::concurrent_hash_map< Key, T, HashCompare, Allocator >::internal_fast_find ( const Key &  key  )  const [inline, protected]

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.

template<typename Key, typename T, typename HashCompare, typename A>
void tbb::interface5::concurrent_hash_map< Key, T, HashCompare, A >::rehash ( size_type  n = 0  ) 

Rehashes and optionally resizes the whole table.

Useful to optimize performance before or after concurrent operations. Also enables using of find() and count() concurrent methods in serial context.


The documentation for this class was generated from the following file:

Copyright © 2005-2013 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.