STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Public Member Functions | Public Types | Friends
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc > Class Template Reference

Container that stores key-value pairs by hashing the key to determine the position in the container where the elements will be stored. More...

Public Member Functions

hasher hash_funct () const
 Returns the hash functor.
 
key_equal key_eq () const
 Returns the comparison functor.
 
allocator_type get_allocator () const
 Returns the allocator.
 
 hash_map ()
 Constructs a default hash map. By default there's 100 buckets.
 
 hash_map (size_type __n)
 Constructs a hash map with a specific number of initial buckets. More...
 
 hash_map (size_type __n, const hasher &__hf)
 Constructs a hash map with a specific number of initial buckets and a hasher. More...
 
 hash_map (size_type __n, const hasher &__hf, const key_equal &__eql, const allocator_type &__a=allocator_type())
 Constructs a hash map with a specific number of initial buckets, a hasher, a comparison object and an allocator. More...
 
template<class _InputIterator >
 hash_map (_InputIterator __f, _InputIterator __l)
 Constructs a default hash map. By default there's 100 buckets. Inserts all the elements in a range of two input iterators. More...
 
template<class _InputIterator >
 hash_map (_InputIterator __f, _InputIterator __l, size_type __n)
 Constructs a hash map with a specific number of initial buckets. More...
 
template<class _InputIterator >
 hash_map (_InputIterator __f, _InputIterator __l, size_type __n, const hasher &__hf)
 Constructs a hash map with a specific number of initial buckets and a hasher. More...
 
template<class _InputIterator >
 hash_map (_InputIterator __f, _InputIterator __l, size_type __n, const hasher &__hf, const key_equal &__eql, const allocator_type &__a=allocator_type())
 Constructs a hash map with a specific number of initial buckets, a hasher, an equality functor and an allocator. More...
 
 hash_map (const value_type *__f, const value_type *__l)
 Constructs a default hash map. By default there's 100 buckets. Inserts all the elements in a range of two input iterators. More...
 
 hash_map (const value_type *__f, const value_type *__l, size_type __n)
 Constructs a hash map with a specific number of initial buckets. More...
 
 hash_map (const value_type *__f, const value_type *__l, size_type __n, const hasher &__hf)
 Constructs a hash map with a specific number of initial buckets and a hasher. More...
 
 hash_map (const value_type *__f, const value_type *__l, size_type __n, const hasher &__hf, const key_equal &__eql, const allocator_type &__a=allocator_type())
 Constructs a hash map with a specific number of initial. buckets, a hasher, a comparison object, and an allocator. More...
 
 hash_map (const_iterator __f, const_iterator __l)
 Constructs a default hash map. By default there's 100 buckets. Inserts all the elements in a range of two input iterators. More...
 
 hash_map (const_iterator __f, const_iterator __l, size_type __n)
 Constructs a hash map with a specific number of initial buckets. More...
 
 hash_map (const_iterator __f, const_iterator __l, size_type __n, const hasher &__hf)
 Constructs a hash map with a specific number of initial buckets and a hasher. More...
 
 hash_map (const_iterator __f, const_iterator __l, size_type __n, const hasher &__hf, const key_equal &__eql, const allocator_type &__a=allocator_type())
 Constructs a hash map with a specific number of initial buckets, a hasher, an equality functor and an allocator. More...
 
size_type size () const
 Returns the number of elements in the container.
 
size_type max_size () const
 Returns the maximum number of elements that can be held in the container.
 
bool empty () const
 Returns whether the container is empty or not.
 
void swap (hash_map &__hs)
 Exchange the content of the container with another one. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
std::pair< iterator, bool > insert (const value_type &__obj)
 Inserts a new element in the container. More...
 
template<class _InputIterator >
void insert (_InputIterator __f, _InputIterator __l)
 Inserts new elements in the container. More...
 
void insert (const value_type *__f, const value_type *__l)
 Inserts new elements in the container. More...
 
void insert (const_iterator __f, const_iterator __l)
 Inserts new elements in the container. More...
 
std::pair< iterator, bool > insert_noresize (const value_type &__obj)
 Inserts a new element in the container without increasing the number of buckets. More...
 
iterator find (const key_type &__key)
 Search for a specific element in the container. More...
 
const_iterator find (const key_type &__key) const
 
_Tp & operator[] (const key_type &__key)
 Access an element with a given key. If no element with the key is present, it inserts a default element with that key. More...
 
size_type count (const key_type &__key) const
 Returns the number of elements with the specified key. More...
 
std::pair< iterator, iteratorequal_range (const key_type &__key)
 Return a range that includes all the elements with a specific key. More...
 
std::pair< const_iterator, const_iteratorequal_range (const key_type &__key) const
 Return a range that includes all the elements with a specific key. More...
 
size_type erase (const key_type &__key)
 Removes all elements with the specified key from the container. More...
 
void erase (iterator __it)
 Removes an element pointed by an iterator from the container. More...
 
void erase (iterator __f, iterator __l)
 Removes some elements pointed by an iterator from the container. More...
 
void clear ()
 Removes all the elements from the container.
 
void resize (size_type __hint)
 Increases the bucket count to at least __hint.
 
size_type bucket_count () const
 Returns the number of buckets used by the container.
 
size_type max_bucket_count () const
 Returns the maximum number of buckets that may be used by the container.
 
size_type elems_in_bucket (size_type __n) const
 Returns the number of elements in a specific bucket.
 
size_type memory_size (void) const
 Returns the size in the memory used by the container.
 

Public Types

typedef _Ht::key_type key_type
 
typedef _Tp data_type
 
typedef _Tp mapped_type
 
typedef _Ht::value_type value_type
 
typedef _Ht::hasher hasher
 
typedef _Ht::key_equal key_equal
 
typedef _Ht::size_type size_type
 
typedef _Ht::difference_type difference_type
 
typedef _Ht::pointer pointer
 
typedef _Ht::const_pointer const_pointer
 
typedef _Ht::reference reference
 
typedef _Ht::const_reference const_reference
 
typedef _Ht::iterator iterator
 
typedef _Ht::const_iterator const_iterator
 
typedef _Ht::allocator_type allocator_type
 

Friends

template<class _K1 , class _T1 , class _HF , class _EqK , class _Al >
bool operator== (const hash_map< _K1, _T1, _HF, _EqK, _Al > &, const hash_map< _K1, _T1, _HF, _EqK, _Al > &)
 

Detailed Description

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
class stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >

Container that stores key-value pairs by hashing the key to determine the position in the container where the elements will be stored.

Template Parameters
_KeyThe hash_map's key type.
_TpThe hash_map value type.
_HashFcnThe hash function used by the hash_map. The default hash function is stapl::hash.
_EqualKeyThe key equality functor. Binary predicate used to compare key values of elements stored in the container for equality. The default equality functor is std::equal_to<_Key>.
_AllocThe hash_map's allocator used for internal memory management. The default allocator is std::allocator<_Tp>.

Constructor & Destructor Documentation

◆ hash_map() [1/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( size_type  __n)
explicit

Constructs a hash map with a specific number of initial buckets.

Parameters
__nThe number of buckets desired.

◆ hash_map() [2/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( size_type  __n,
const hasher &  __hf 
)

Constructs a hash map with a specific number of initial buckets and a hasher.

Parameters
__nThe number of buckets desired.
__hfThe hash functor.

◆ hash_map() [3/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( size_type  __n,
const hasher &  __hf,
const key_equal &  __eql,
const allocator_type &  __a = allocator_type() 
)

Constructs a hash map with a specific number of initial buckets, a hasher, a comparison object and an allocator.

Parameters
__nThe number of buckets desired.
__hfThe hash functor.
__eqlThe comparison object.
__aThe allocator. By default a new one is constructed.

◆ hash_map() [4/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
template<class _InputIterator >
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( _InputIterator  __f,
_InputIterator  __l 
)

Constructs a default hash map. By default there's 100 buckets. Inserts all the elements in a range of two input iterators.

Parameters
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l)

◆ hash_map() [5/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
template<class _InputIterator >
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( _InputIterator  __f,
_InputIterator  __l,
size_type  __n 
)

Constructs a hash map with a specific number of initial buckets.

Parameters
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l).
__nThe number of buckets desired.

◆ hash_map() [6/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
template<class _InputIterator >
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( _InputIterator  __f,
_InputIterator  __l,
size_type  __n,
const hasher &  __hf 
)

Constructs a hash map with a specific number of initial buckets and a hasher.

Parameters
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l).
__nThe number of buckets desired.
__hfThe hash functor.

◆ hash_map() [7/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
template<class _InputIterator >
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( _InputIterator  __f,
_InputIterator  __l,
size_type  __n,
const hasher &  __hf,
const key_equal &  __eql,
const allocator_type &  __a = allocator_type() 
)

Constructs a hash map with a specific number of initial buckets, a hasher, an equality functor and an allocator.

Parameters
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l)
__nThe number of buckets desired.
__hfThe hash functor.
__eqlThe equality functor.
__aThe allocator. By default a new one is constructed.

◆ hash_map() [8/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( const value_type *  __f,
const value_type *  __l 
)

Constructs a default hash map. By default there's 100 buckets. Inserts all the elements in a range of two input iterators.

Parameters
__f,__lPointers delimiting a range of elements to insert. The range of elements is [__f,__l)

◆ hash_map() [9/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( const value_type *  __f,
const value_type *  __l,
size_type  __n 
)

Constructs a hash map with a specific number of initial buckets.

Parameters
__nThe number of buckets desired.
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l).

◆ hash_map() [10/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( const value_type *  __f,
const value_type *  __l,
size_type  __n,
const hasher &  __hf 
)

Constructs a hash map with a specific number of initial buckets and a hasher.

Parameters
__f,__lPointers delimiting a range of elements to insert. The range of elements is [__f,__l).
__nThe number of buckets desired.
__hfThe hash functor.

◆ hash_map() [11/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( const value_type *  __f,
const value_type *  __l,
size_type  __n,
const hasher &  __hf,
const key_equal &  __eql,
const allocator_type &  __a = allocator_type() 
)

Constructs a hash map with a specific number of initial. buckets, a hasher, a comparison object, and an allocator.

Parameters
__f,__lPointers delimiting a range of elements to insert. The range of elements is [__f,__l).
__nThe number of buckets desired.
__hfThe hash functor.
__eqlThe comparison object.
__aThe allocator. By default a new one is constructed.

◆ hash_map() [12/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( const_iterator  __f,
const_iterator  __l 
)

Constructs a default hash map. By default there's 100 buckets. Inserts all the elements in a range of two input iterators.

Parameters
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l)

◆ hash_map() [13/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( const_iterator  __f,
const_iterator  __l,
size_type  __n 
)

Constructs a hash map with a specific number of initial buckets.

Parameters
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l).
__nThe number of buckets desired.

◆ hash_map() [14/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( const_iterator  __f,
const_iterator  __l,
size_type  __n,
const hasher &  __hf 
)

Constructs a hash map with a specific number of initial buckets and a hasher.

Parameters
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l).
__nThe number of buckets desired.
__hfThe hash functor.

◆ hash_map() [15/15]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::hash_map ( const_iterator  __f,
const_iterator  __l,
size_type  __n,
const hasher &  __hf,
const key_equal &  __eql,
const allocator_type &  __a = allocator_type() 
)

Constructs a hash map with a specific number of initial buckets, a hasher, an equality functor and an allocator.

Parameters
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l)
__nThe number of buckets desired.
__hfThe hash functor.
__eqlThe equality functor.
__aThe allocator. By default a new one is constructed.

Member Function Documentation

◆ swap()

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
void stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::swap ( hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc > &  __hs)

Exchange the content of the container with another one.

Parameters
__hsThe container which swaps elements of the same type.

◆ insert() [1/4]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
std::pair<iterator,bool> stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::insert ( const value_type &  __obj)

Inserts a new element in the container.

Parameters
__objThe element to be inserted. It is a pair<key,value>.
Returns
A pair containing an iterator pointing to the element whose key is the same as the key of the element to insert, and a bool value that indicates whether the element was successfully inserted or not.

◆ insert() [2/4]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
template<class _InputIterator >
void stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::insert ( _InputIterator  __f,
_InputIterator  __l 
)

Inserts new elements in the container.

Parameters
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l).

◆ insert() [3/4]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
void stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::insert ( const value_type *  __f,
const value_type *  __l 
)

Inserts new elements in the container.

Parameters
__f,__lPointers delimiting a range of elements to insert. The range of elements is [__f,__l).

◆ insert() [4/4]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
void stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::insert ( const_iterator  __f,
const_iterator  __l 
)

Inserts new elements in the container.

Parameters
__f,__lInput iterators delimiting a range of elements to insert. The range of elements is [__f,__l).

◆ insert_noresize()

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
std::pair<iterator,bool> stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::insert_noresize ( const value_type &  __obj)

Inserts a new element in the container without increasing the number of buckets.

Parameters
__objThe element to be inserted. It is a pair<key,value>.
Returns
A pair containing an iterator pointing to the element whose key is the same as the key of the element to insert, and a bool value that indicates whether the element was successfully inserted or not.

◆ find()

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
iterator stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::find ( const key_type &  __key)

Search for a specific element in the container.

Parameters
__keyThe key indexing the element.
Returns
Iterator to the element, or to the end if no element is found.

◆ operator[]()

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
_Tp& stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::operator[] ( const key_type &  __key)

Access an element with a given key. If no element with the key is present, it inserts a default element with that key.

Parameters
__keyThe key indexing the element.
Returns
Reference to the mapped value of the element

◆ count()

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
size_type stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::count ( const key_type &  __key) const

Returns the number of elements with the specified key.

Parameters
__keyThe key indexing the element.

◆ equal_range() [1/2]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
std::pair<iterator, iterator> stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::equal_range ( const key_type &  __key)

Return a range that includes all the elements with a specific key.

Parameters
__keyThe key indexing the element.
Returns
Pair of iterators delimiting a range of elements The range of elements is [pair's first, pair's second).

◆ equal_range() [2/2]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
std::pair<const_iterator, const_iterator> stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::equal_range ( const key_type &  __key) const

Return a range that includes all the elements with a specific key.

Parameters
__keyThe key indexing the element.
Returns
Pair of iterators delimiting a range of elements The range of elements is [pair's first, pair's second).

◆ erase() [1/3]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
size_type stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::erase ( const key_type &  __key)

Removes all elements with the specified key from the container.

Parameters
__keyThe key indexing the element.
Returns
The number of elements removed from the container.

◆ erase() [2/3]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
void stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::erase ( iterator  __it)

Removes an element pointed by an iterator from the container.

Parameters
__itThe iterator over the element to delete.

◆ erase() [3/3]

template<class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
void stapl::hash_map< _Key, _Tp, _HashFcn, _EqualKey, _Alloc >::erase ( iterator  __f,
iterator  __l 
)

Removes some elements pointed by an iterator from the container.

Parameters
__f,__lInput iterators delimiting a range of elements to delete. The range of elements is [__f,__l).

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