BDE 4.14.0 Production release
|
#include <bslstl_unorderedmap.h>
Public Types | |
typedef KEY | key_type |
typedef VALUE | mapped_type |
typedef bsl::pair< const KEY, VALUE > | value_type |
typedef HASH | hasher |
typedef EQUAL | key_equal |
typedef ALLOCATOR | allocator_type |
typedef value_type & | reference |
typedef const value_type & | const_reference |
typedef AllocatorTraits::size_type | size_type |
typedef AllocatorTraits::difference_type | difference_type |
typedef AllocatorTraits::pointer | pointer |
typedef AllocatorTraits::const_pointer | const_pointer |
typedef BloombergLP::bslstl::HashTableIterator< value_type, difference_type > | iterator |
typedef BloombergLP::bslstl::HashTableIterator< const value_type, difference_type > | const_iterator |
typedef BloombergLP::bslstl::HashTableBucketIterator< value_type, difference_type > | local_iterator |
typedef BloombergLP::bslstl::HashTableBucketIterator< const value_type, difference_type > | const_local_iterator |
Public Member Functions | |
unordered_map (size_type initialNumBuckets, const HASH &hashFunction=HASH(), const EQUAL &keyEqual=EQUAL(), const ALLOCATOR &basicAllocator=ALLOCATOR()) | |
unordered_map (size_type initialNumBuckets, const HASH &hashFunction, const ALLOCATOR &basicAllocator) | |
unordered_map (size_type initialNumBuckets, const ALLOCATOR &basicAllocator) | |
unordered_map (const ALLOCATOR &basicAllocator) | |
unordered_map () | |
template<class INPUT_ITERATOR > | |
unordered_map (INPUT_ITERATOR first, INPUT_ITERATOR last, size_type initialNumBuckets=0, const HASH &hashFunction=HASH(), const EQUAL &keyEqual=EQUAL(), const ALLOCATOR &basicAllocator=ALLOCATOR()) | |
template<class INPUT_ITERATOR > | |
unordered_map (INPUT_ITERATOR first, INPUT_ITERATOR last, size_type initialNumBuckets, const HASH &hashFunction, const ALLOCATOR &basicAllocator) | |
template<class INPUT_ITERATOR > | |
unordered_map (INPUT_ITERATOR first, INPUT_ITERATOR last, size_type initialNumBuckets, const ALLOCATOR &basicAllocator) | |
template<class INPUT_ITERATOR > | |
unordered_map (INPUT_ITERATOR first, INPUT_ITERATOR last, const ALLOCATOR &basicAllocator) | |
unordered_map (const unordered_map &original) | |
unordered_map (const unordered_map &original, const typename type_identity< ALLOCATOR >::type &basicAllocator) | |
unordered_map (BloombergLP::bslmf::MovableRef< unordered_map > original) | |
unordered_map (BloombergLP::bslmf::MovableRef< unordered_map > original, const typename type_identity< ALLOCATOR >::type &basicAllocator) | |
~unordered_map () | |
Destroy this object and each of its elements. | |
unordered_map & | operator= (const unordered_map &rhs) |
unordered_map &operator=(BloombergLP::bslmf::MovableRef< unordered_map > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits add_lvalue_reference< VALUE >::type | operator[] (const key_type &key) |
add_lvalue_reference< VALUE >::type | operator[] (BloombergLP::bslmf::MovableRef< key_type > key) |
add_lvalue_reference< VALUE >::type | at (const key_type &key) |
iterator | begin () BSLS_KEYWORD_NOEXCEPT |
iterator | end () BSLS_KEYWORD_NOEXCEPT |
local_iterator | begin (size_type index) |
local_iterator | end (size_type index) |
void | clear () BSLS_KEYWORD_NOEXCEPT |
template<class... Args> | |
pair< iterator, bool > | emplace (Args &&... args) |
template<class... Args> | |
iterator | emplace_hint (const_iterator hint, Args &&... args) |
iterator | erase (const_iterator position) |
iterator | erase (iterator position) |
size_type | erase (const key_type &key) |
iterator | erase (const_iterator first, const_iterator last) |
template<class LOOKUP_KEY > | |
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, iterator >::type | find (const LOOKUP_KEY &key) |
iterator | find (const key_type &key) |
pair< iterator, bool > | insert (const value_type &value) |
template<class ALT_VALUE_TYPE > | |
enable_if< is_convertible< ALT_VALUE_TYPE, value_type >::value, pair< iterator, bool > >::type | insert (BSLS_COMPILERFEATURES_FORWARD_REF(ALT_VALUE_TYPE) value) |
iterator | insert (const_iterator hint, const value_type &value) |
template<class ALT_VALUE_TYPE > | |
enable_if< is_convertible< ALT_VALUE_TYPE, value_type >::value, iterator >::type | insert (const_iterator hint, BSLS_COMPILERFEATURES_FORWARD_REF(ALT_VALUE_TYPE) value) |
template<class INPUT_ITERATOR > | |
void | insert (INPUT_ITERATOR first, INPUT_ITERATOR last) |
template<class BDE_OTHER_TYPE > | |
pair< iterator, bool > | insert_or_assign (const KEY &key, BDE_OTHER_TYPE &&obj) |
template<class BDE_OTHER_TYPE > | |
pair< iterator, bool > | insert_or_assign (BloombergLP::bslmf::MovableRef< KEY > key, BDE_OTHER_TYPE &&obj) |
template<class BDE_OTHER_TYPE > | |
iterator | insert_or_assign (const_iterator hint, const KEY &key, BDE_OTHER_TYPE &&obj) |
template<class BDE_OTHER_TYPE > | |
iterator | insert_or_assign (const_iterator hint, BloombergLP::bslmf::MovableRef< KEY > key, BDE_OTHER_TYPE &&obj) |
template<class LOOKUP_KEY > | |
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, pair< iterator, iterator > >::type | equal_range (const LOOKUP_KEY &key) |
pair< iterator, iterator > | equal_range (const key_type &key) |
void | max_load_factor (float newMaxLoadFactor) |
void | rehash (size_type numBuckets) |
void | reserve (size_type numElements) |
template<class... Args> | |
pair< iterator, bool > | try_emplace (BloombergLP::bslmf::MovableRef< KEY > key, Args &&... args) |
template<class LOOKUP_KEY , class... Args> | |
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value &&!bsl::is_convertible< LOOKUP_KEY &&, const_iterator >::value &&!bsl::is_convertible< LOOKUP_KEY &&, iterator >::value, pair< iterator, bool > >::type | try_emplace (LOOKUP_KEY &&key, Args &&... args) |
template<class... Args> | |
iterator | try_emplace (const_iterator hint, const KEY &key, Args &&... args) |
template<class... Args> | |
iterator | try_emplace (const_iterator hint, BloombergLP::bslmf::MovableRef< KEY > key, Args &&... args) |
template<class LOOKUP_KEY , class... Args> | |
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, iterator >::type | try_emplace (const_iterator hint, LOOKUP_KEY &&key, Args &&... args) |
add_lvalue_reference< constVALUE >::type | at (const key_type &key) const |
const_iterator | begin () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | cbegin () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | end () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | cend () const BSLS_KEYWORD_NOEXCEPT |
const_local_iterator | begin (size_type index) const |
const_local_iterator | cbegin (size_type index) const |
const_local_iterator | end (size_type index) const |
const_local_iterator | cend (size_type index) const |
size_type | bucket (const key_type &key) const |
size_type | bucket_count () const BSLS_KEYWORD_NOEXCEPT |
size_type | max_bucket_count () const BSLS_KEYWORD_NOEXCEPT |
size_type | bucket_size (size_type index) const |
template<class LOOKUP_KEY > | |
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, size_type >::type | count (const LOOKUP_KEY &key) const |
size_type | count (const key_type &key) const |
bool | contains (const key_type &key) const |
template<class LOOKUP_KEY > | |
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, bool >::type | contains (const LOOKUP_KEY &key) const |
bool | empty () const BSLS_KEYWORD_NOEXCEPT |
template<class LOOKUP_KEY > | |
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, pair< const_iterator, const_iterator > >::type | equal_range (const LOOKUP_KEY &key) const |
pair< const_iterator, const_iterator > | equal_range (const key_type &key) const |
template<class LOOKUP_KEY > | |
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, const_iterator >::type | find (const LOOKUP_KEY &key) const |
const_iterator | find (const key_type &key) const |
allocator_type | get_allocator () const BSLS_KEYWORD_NOEXCEPT |
HASH | hash_function () const |
EQUAL | key_eq () const |
float | load_factor () const BSLS_KEYWORD_NOEXCEPT |
float | max_load_factor () const BSLS_KEYWORD_NOEXCEPT |
size_type | size () const BSLS_KEYWORD_NOEXCEPT |
Return the number of elements in this unordered map. | |
size_type | max_size () const BSLS_KEYWORD_NOEXCEPT |
template<class... Args> | |
bsl::pair< typename unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator, bool > | emplace (Args &&... args) |
template<class BDE_OTHER_TYPE > | |
bsl::pair< typename unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator, bool > | insert_or_assign (const KEY &key, BDE_OTHER_TYPE &&obj) |
template<class BDE_OTHER_TYPE > | |
bsl::pair< typename unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator, bool > | insert_or_assign (BloombergLP::bslmf::MovableRef< KEY > key, BDE_OTHER_TYPE &&obj) |
template<class... Args> | |
bsl::pair< typename bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator, bool > | try_emplace (const KEY &key, Args &&... args) |
template<class... Args> | |
bsl::pair< typename bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator, bool > | try_emplace (BloombergLP::bslmf::MovableRef< KEY > key, Args &&... args) |
template<class... Args> | |
bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator | try_emplace (const_iterator hint, const KEY &key, Args &&... args) |
template<class... Args> | |
bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator | try_emplace (const_iterator hint, BloombergLP::bslmf::MovableRef< KEY > key, Args &&... args) |
Public Attributes | |
template<class... Args> | |
void swap(unordered_map &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits pair< iterator, bool > | try_emplace (const KEY &key, Args &&... args) |
Friends | |
template<class KEY2 , class VALUE2 , class HASH2 , class EQUAL2 , class ALLOCATOR2 > | |
bool | operator== (const unordered_map< KEY2, VALUE2, HASH2, EQUAL2, ALLOCATOR2 > &, const unordered_map< KEY2, VALUE2, HASH2, EQUAL2, ALLOCATOR2 > &) |
This class template implements a value-semantic container type holding an unordered set of KEY-VALUE
pairs having unique keys that provide a mapping from keys (of template parameter type KEY
) to their associated mapped values (of template parameter type VALUE
).
This class:
at
method)const
thread-safe For terminology see bsldoc_glossary .typedef ALLOCATOR bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::allocator_type |
typedef BloombergLP::bslstl::HashTableIterator< const value_type, difference_type> bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::const_iterator |
typedef BloombergLP::bslstl::HashTableBucketIterator< const value_type, difference_type> bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::const_local_iterator |
typedef AllocatorTraits::const_pointer bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::const_pointer |
typedef const value_type& bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::const_reference |
typedef AllocatorTraits::difference_type bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::difference_type |
typedef HASH bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::hasher |
typedef BloombergLP::bslstl::HashTableIterator< value_type, difference_type> bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator |
typedef EQUAL bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::key_equal |
typedef KEY bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::key_type |
typedef BloombergLP::bslstl::HashTableBucketIterator< value_type, difference_type> bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::local_iterator |
typedef VALUE bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::mapped_type |
typedef AllocatorTraits::pointer bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::pointer |
typedef value_type& bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::reference |
typedef AllocatorTraits::size_type bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::size_type |
typedef bsl::pair<const KEY, VALUE> bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::value_type |
|
inlineexplicit |
|
inline |
|
inline |
|
inlineexplicit |
|
inline |
Create an empty unordered map having a max_load_factor
of 1.0. Optionally specify an initialNumBuckets
indicating the minimum initial size of the array of buckets of this unordered map. If initialNumBuckets
is not supplied, one empty bucket shall be used and no memory allocated. Optionally specify a hashFunction
used to generate the hash values associated with the KEY-VALUE
pairs contained in this unordered map. If hashFunction
is not supplied, a default-constructed object of the (template parameter) type HASH
is used. Optionally specify a key-equality functor keyEqual
used to determine whether two keys are equivalent. If keyEqual
is not supplied, a default-constructed object of the (template parameter) type EQUAL
is used. Optionally specify the basicAllocator
used to supply memory. If basicAllocator
is not supplied, a default-constructed object of the (template parameter) type ALLOCATOR
is used. If the ALLOCATOR
type is bsl::allocator
(the default), then basicAllocator
shall be convertible to bslma::Allocator *
. If the ALLOCATOR
type is bsl::allocator
and basicAllocator
is not supplied, the currently installed default allocator is used to supply memory. Note that more than initialNumBuckets
buckets may be created in order to preserve the bucket allocation strategy of the hash-table (but never fewer).
|
inline |
Create an empty unordered map, having a max_load_factor
of 1.0, and then create a value_type
object for each iterator in the range starting at the specified first
iterator and ending immediately before the specified last
iterator, by converting from the object referred to by each iterator. Insert into this unordered map each such object, ignoring those having a key that appears earlier in the sequence. Optionally specify a minimum initialNumBuckets
indicating the minimum initial size of the array of buckets of this unordered map. If initialNumBuckets
is 0 or not supplied, and first
and last
denote an empty range, a single empty bucket shall be supplied. The actual number of buckets the unordered_map is created with shall always be enough to accommodate the number of elements of the range without exceeding the max_load_factor
. Optionally specify a hashFunction
used to generate hash values associated with the KEY-VALUE
pairs contained in this unordered map. If hashFunction
is not supplied, a default-constructed object of the (template parameter) type HASH
is used. Optionally specify a key-equality functor keyEqual
used to verify that two keys are equivalent. If keyEqual
is not supplied, a default-constructed object of the (template parameter) type EQUAL
is used. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is not supplied, a default-constructed object of the (template parameter) type ALLOCATOR
is used. If ALLOCATOR
type is bsl::allocator
(the default), then basicAllocator
shall be convertible to bslma::Allocator *
. If the ALLOCATOR
type is bsl::allocator
and basicAllocator
is not supplied, the currently installed default allocator is used to supply memory. The (template parameter) type INPUT_ITERATOR
shall meet the requirements of an input iterator defined in the C++11 standard [24.2.3] providing access to values of a type convertible to value_type
. The behavior is undefined unless first
and last
refer to a sequence of valid values where first
is at a position at or before last
. Note that more than initialNumBuckets
buckets may be created in order to preserve the bucket allocation strategy of the hash-table (but never fewer).
|
inline |
|
inline |
|
inline |
|
inline |
Create an unordered map having the same value, hasher, key-equality comparator, and max_load_factor
as the specified original
. Use the allocator returned by 'bsl::allocator_traits<ALLOCATOR>:: select_on_container_copy_construction(original.get_allocator())' to supply memory. If the ALLOCATOR
type is bsl::allocator
(the default), the currently installed default allocator is used to supply memory.
|
inline |
Create an unordered map having the same value, hasher, key-equality comparator, and max_load_factor
as the specified original
, and using the specified basicAllocator
to supply memory. If the ALLOCATOR
type is bsl::allocator
(the default), then basicAllocator
shall be convertible to bslma::Allocator *
.
|
inline |
Create an unordered map having the same value as the specified original
object by moving (in constant time) the contents of original
to the new unordered map. Use a copy of original.hash_function()
to generate hash values for the keys contained in this unordered map. Use a copy of original.key_eq()
to verify that two keys are equivalent. The allocator associated with original
is propagated for use in the newly-created unordered map. original
is left in a valid but unspecified state.
|
inline |
Create an unordered map having the same value, hasher, key-equality comparator, and max_load_factor
as the specified original
. Use the specified basicAllocator
to supply memory. This method requires that the (template parameter) type value_type
be move-insertable
into this unordered_map
(see {Requirements on value_type
}). Note that a bslma::Allocator *
can be supplied for basicAllocator
if the (template parameter) ALLOCATOR
type is bsl::allocator
(the default).
|
inline |
|
inline |
Return a reference providing modifiable access to the mapped-value associated with the specified key
, if such an entry exists; otherwise throw std::out_of_range
exception. Note that this method is not exception-neutral.
add_lvalue_reference< constVALUE >::type bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::at | ( | const key_type & | key | ) | const |
Return a reference providing non-modifiable access to the mapped-value associated with the specified key
, if such an entry exists; otherwise throw a std::out_of_range
exception. Note that this method is not exception-neutral.
|
inline |
Return an iterator providing modifiable access to the first value_type
object in the sequence of value_type
objects maintained by this unordered map, or the end
iterator if this unordered map is empty.
|
inline |
|
inline |
Return a local iterator providing modifiable access to the first value_type
object in the sequence of value_type
objects of the bucket having the specified index
in the array of buckets maintained by this unordered map, or the end(index)
iterator if the bucket is empty. The behavior is undefined unless 'index < bucket_count()'.
|
inline |
|
inline |
Return the index of the bucket, in the array of buckets maintained by this unordered map, where values having a key equivalent to the specified key
would be inserted.
|
inline |
Return the number of buckets in the array of buckets maintained by this unordered map.
|
inline |
Return the number of elements contained in the bucket at the specified index
in the array of buckets maintained by this unordered map. The behavior is undefined unless index < bucket_count()
.
|
inline |
Return an iterator providing non-modifiable access to the first value_type
object in the sequence of value_type
objects maintained by this unordered map, or the end
iterator if this unordered map is empty.
|
inline |
Return a local iterator providing non-modifiable access to the first value_type
object in the sequence of value_type
objects of the bucket having the specified index
in the array of buckets maintained by this unordered map, or the end(index)
iterator if the bucket is empty. The behavior is undefined unless index < bucket_count()
.
|
inline |
Return an iterator providing non-modifiable access to the past-the-end position in the sequence of value_type
objects maintained by this unordered map.
|
inline |
Return a local iterator providing non-modifiable access to the past-the-end position in the sequence of value_type
objects of the bucket having the specified index
in the array of buckets maintained by this unordered map. The behavior is undefined unless index < bucket_count()
.
|
inline |
Remove all entries from this unordered map. Note that this unordered map will be empty after calling this method, but allocated memory may be retained for future use.
|
inline |
Return true
if this unordered map contains an element whose key is equivalent to the specified key
.
|
inline |
Return true
if this unordered map contains an element whose key is equivalent to the specified key
.
Note: implemented inline due to Sun CC compilation error
|
inline |
Return the number of value_type
objects contained within this unordered map having the specified key
. Note that since an unordered map maintains unique keys, the returned value will be either 0 or 1.
|
inline |
Return the number of value_type
objects within this unordered map that have a key equivalent to the specified key
. The behavior is undefined unless key
is equivalent to at most one key in this unordered map. Note that since an unordered map maintains unique keys, the returned value will be either 0 or 1.
Note: implemented inline due to Sun CC compilation error.
pair< iterator, bool > bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::emplace | ( | Args &&... | args | ) |
Insert into this unordered map a newly-created value_type
object, constructed by forwarding get_allocator()
(if required) and the specified (variable number of) args
to the corresponding constructor of value_type
, if a key equivalent to such a value does not already exist in this map; otherwise, this method has no effect (other than possibly creating a temporary value_type
object). Return a pair whose first
member is an iterator referring to the (possibly newly created and inserted) object in this map whose key is equivalent to that of an object constructed from args
, and whose second
member is true
if a new value was inserted, and false
if an equivalent key was already present. This method requires that the (template parameter) types KEY
and VALUE
both be emplace-constructible
from args
(see {Requirements on value_type
}).
bsl::pair< typename unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator, bool > bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::emplace | ( | Args &&... | args | ) |
unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::emplace_hint | ( | const_iterator | hint, |
Args &&... | args | ||
) |
Insert into this unordered map a newly-created value_type
object, constructed by forwarding get_allocator()
(if required) and the specified (variable number of) args
to the corresponding constructor of value_type
, if a key equivalent to such a value does not already exist in this map; otherwise, this method has no effect (other than possibly creating a temporary value_type
object). Return an iterator referring to the (possibly newly created and inserted) object in this map whose key is equivalent to that of an object constructed from args
. The average and worst case complexity of this operation is not affected by the specified hint
. This method requires that the (template parameter) types KEY
and VALUE
both be emplace-constructible
from args
(see {Requirements on value_type
}). The behavior is undefined unless hint
is an iterator in the range [begin() .. end()]
(both endpoints included). Note that hint
is ignored (other than possibly asserting its validity in some build modes).
|
inline |
Return true
if this unordered map contains no elements, and false
otherwise.
|
inline |
Return an iterator providing modifiable access to the past-the-end position in the sequence of value_type
objects maintained by this unordered map.
|
inline |
|
inline |
Return a local iterator providing modifiable access to the past-the-end position in the sequence of value_type
objects of the bucket having the specified index
in the array of buckets maintained by this unordered map. The behavior is undefined unless index < bucket_count()
.
|
inline |
bsl::pair< typename unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator, typename unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator > bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::equal_range | ( | const key_type & | key | ) |
Return a pair of iterators providing modifiable access to the sequence of value_type
objects in this unordered map having the specified key
, where the first iterator is positioned at the start of the sequence, and the second is positioned one past the end of the sequence. If this unordered map contains no value_type
object having key
, then the two returned iterators will have the same value, end()
. Note that since an unordered map maintains unique keys, the range will contain at most one element.
bsl::pair< typename unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::const_iterator, typename unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::const_iterator > bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::equal_range | ( | const key_type & | key | ) | const |
Return a pair of iterators providing non-modifiable access to the sequence of value_type
objects in this unordered map having the specified key
, where the first iterator is positioned at the start of the sequence, and the second is positioned one past the end of the sequence. If this unordered map contains no value_type
object having key
, then the two returned iterators will have the same value, end()
. Note that since an unordered map maintains unique keys, the range will contain at most one element.
|
inline |
Return a pair of iterators providing modifiable access to the sequence of value_type
objects in this unordered map having the specified key
, where the first iterator is positioned at the start of the sequence, and the second is positioned one past the end of the sequence. If this unordered map contains no value_type
object having key
, then the two returned iterators will have the same value, end()
. The behavior is undefined unless key
is equivalent to at most one key in this unordered map. Note that since an unordered map maintains unique keys, the range will contain at most one element.
Note: implemented inline due to Sun CC compilation error.
|
inline |
Return a pair of iterators providing non-modifiable access to the sequence of value_type
objects in this unordered map with a key equivalent to specified key
, where the first iterator is positioned at the start of the sequence, and the second is positioned one past the end of the sequence. If this unordered map contains no value_type
objects having a key equivalent to key
, then the two returned iterators will have the same value, end()
. The behavior is undefined unless key
is equivalent to at most one key in this unordered map. Note that since an unordered map maintains unique keys, the range will contain at most one element.
Note: implemented inline due to Sun CC compilation error.
unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::size_type bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::erase | ( | const key_type & | key | ) |
Remove from this unordered map the value_type
object having the specified key
, if it exists, and return 1; otherwise (there is no object with a key equivalent to key
in this unordered map) return 0 with no other effect. This method invalidates only iterators and references to the removed element and previously saved values of the end()
iterator, and preserves the relative order of the elements not removed.
unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::erase | ( | const_iterator | first, |
const_iterator | last | ||
) |
Remove from this unordered map the value_type
objects starting at the specified first
position up to, but not including, the specified last
position, and return last
. This method invalidates only iterators and references to the removed element and previously saved values of the end()
iterator, and preserves the relative order of the elements not removed. The behavior is undefined unless first
and last
either refer to elements in this unordered map or are the end
iterator, and the first
position is at or before the last
position in the iteration sequence provided by this container.
|
inline |
|
inline |
Remove from this unordered map the value_type
object at the specified position
, and return an iterator referring to the element immediately following the removed element, or to the past-the-end position if the removed element was the last element in the sequence of elements maintained by this unordered map. This method invalidates only iterators and references to the removed element and previously saved values of the end()
iterator, and preserves the relative order of the elements not removed. The behavior is undefined unless position
refers to a value_type
object in this unordered map.
|
inline |
Return an iterator providing modifiable access to the value_type
object in this unordered map with a key equivalent to the specified key
, if such an entry exists, and the past-the-end iterator (end
) otherwise.
|
inline |
Return an iterator providing non-modifiable access to the value_type
object in this unordered map with a key equivalent to the specified key
, if such an entry exists, and the past-the-end iterator (end
) otherwise.
|
inline |
Return an iterator providing modifiable access to the value_type
object in this unordered map with a key equivalent to the specified key
, if such an entry exists, and the past-the-end iterator (end
) otherwise. The behavior is undefined unless key
is equivalent to the key of at most one element in this unordered map.
|
inline |
Return an iterator providing non-modifiable access to the value_type
object in this unordered map with a key equivalent to the specified key
, if such an entry exists, and the past-the-end iterator (end
) otherwise. The behavior is undefined unless key
is equivalent to at most one key in this unordered map.
Note: implemented inline due to Sun CC compilation error.
|
inline |
Return (a copy of) the allocator used for memory allocation by this unordered map.
|
inline |
Return (a copy of) the unary hash functor used by this unordered map to generate a hash value (of type size_type
) for a key_type
object.
|
inline |
|
inline |
Insert the specified value
into this unordered map if the key (the first
element) of the object referred to by value
does not already exist in this unordered map; otherwise, this method has no effect (a value_type
object having the key equivalent to the key of value
already exists in this unordered map). Return a pair
whose first
member is an iterator referring to the (possibly newly inserted) value_type
object in this unordered map whose key is equivalent to that of the object to be inserted, and whose second
member is true
if a new value was inserted, and false
if a value having an equivalent key was already present. Note that this method requires that the (template parameter) types KEY
and VALUE
both be copy-insertable
into this unordered map (see {Requirements on value_type
}).
|
inline |
|
inline |
Insert the specified value
into this unordered map if the key (the first
element) of the object referred to by value
does not already exist in this unordered map; otherwise, this method has no effect (a value_type
object having the key equivalent to the key of value
already exists in this unordered map). Return an iterator referring to ether the newly inserted value_type
object or to the existing object whose key is equivalent to the key of value
. The average and worst case complexity of this operation is not affected by the specified hint
. This method requires that the (template parameter) types KEY
and VALUE
both be copy-insertable
into this unordered map (see {Requirements on value_type
}). The behavior is undefined unless hint
is an iterator in the range [begin() .. end()]
(both endpoints included). Note that hint
is ignored (other than possibly asserting its validity in some build modes).
void bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::insert | ( | INPUT_ITERATOR | first, |
INPUT_ITERATOR | last | ||
) |
Create a value_type
object for each iterator in the range starting at the specified first
iterator and ending immediately before the specified last
iterator, by converting from the object referred to by each iterator. Insert into this unordered map each such object whose key is not already contained. The (template parameter) type INPUT_ITERATOR
shall meet the requirements of an input iterator defined in the C++11 standard [24.2.3] providing access to values of a type convertible to value_type
. The behavior is undefined unless first
and last
refer to a sequence of valid values where first
is at a position at or before last
. Note that this method requires that the (template parameter) types KEY
and VALUE
both be copy-constructible
(see {Requirements on value_type
}).
pair< iterator, bool > bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::insert_or_assign | ( | BloombergLP::bslmf::MovableRef< KEY > | key, |
BDE_OTHER_TYPE && | obj | ||
) |
If a key equivalent to the specified key
already exists in this unordered_map, assign the specified obj
to the value associated with that key, and return a pair containing an iterator referring to the existing item and false
. Otherwise, insert into this map a newly-created value_type
object, constructed from (std::forward<KEY>(key), std::forward<BDE_OTHER_TYPE>(obj)...))
, and return a pair containing an iterator referring to the newly-created entry and true
.
bsl::pair< typename unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator, bool > bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::insert_or_assign | ( | BloombergLP::bslmf::MovableRef< KEY > | key, |
BDE_OTHER_TYPE && | obj | ||
) |
pair< iterator, bool > bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::insert_or_assign | ( | const KEY & | key, |
BDE_OTHER_TYPE && | obj | ||
) |
If a key equivalent to the specified key
already exists in this unordered_map, assign the specified obj
to the value associated with that key, and return a pair containing an iterator referring to the existing item and false
. Otherwise, insert into this map a newly-created value_type
object, constructed from (key, std::forward<BDE_OTHER_TYPE>(obj)...))
, and return a pair containing an iterator referring to the newly-created entry and true
.
bsl::pair< typename unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator, bool > bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::insert_or_assign | ( | const KEY & | key, |
BDE_OTHER_TYPE && | obj | ||
) |
unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::insert_or_assign | ( | const_iterator | hint, |
BloombergLP::bslmf::MovableRef< KEY > | key, | ||
BDE_OTHER_TYPE && | obj | ||
) |
If a key equivalent to the specified key
already exists in this unordered_map, assign the specified obj
to the value associated with that key, and return an iterator referring to the existing item. Otherwise, insert into this map a newly-created value_type
object, constructed from (std::forward<KEY>(key), std::forward<BDE_OTHER_TYPE>(obj)...))
, and return an iterator referring to the newly-created entry. Use the specified hint
as a starting point for checking to see if the key already in the unordered_map.
unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::iterator bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::insert_or_assign | ( | const_iterator | hint, |
const KEY & | key, | ||
BDE_OTHER_TYPE && | obj | ||
) |
If a key equivalent to the specified key
already exists in this unordered_map, assign the specified obj
to the value associated with that key, and return an iterator referring to the existing item. Otherwise, insert into this map a newly-created value_type
object, constructed from (std::forward<KEY>(key), std::forward<BDE_OTHER_TYPE>(obj)...))
, and return a pair containing an iterator referring to the newly-created entry and true
. Use the specified hint
as a starting point for checking to see if the key already in the unordered_map.
|
inline |
Return (a copy of) binary the key-equality functor used by this unordered map that returns true
if two key_type
objects are equivalent, and false
otherwise.
|
inline |
Return the current ratio between the size
of this unordered map and the number of buckets. The load factor is a measure of how full the container is, and a higher load factor typically leads to an increased number of collisions, thus resulting in a loss of performance.
|
inline |
Return a theoretical upper bound on the largest number of buckets that this unordered map could possibly manage. Note that there is no guarantee that the unordered map can successfully grow to the returned size, or even close to that size, without running out of resources.
|
inline |
Return the maximum load factor allowed for this unordered map. Note that if an insert operation would cause the load factor to exceed the max_load_factor
, that same insert operation will increase the number of buckets and rehash the elements of the container into those buckets (see rehash
).
|
inline |
Set the maximum load factor of this unordered map to the specified newMaxLoadFactor
. If newMaxLoadFactor < loadFactor()
, this operator will cause an immediate rehash (in violation of the C++11 standard); otherwise, it has a constant-time cost. The behavior is undefined unless 0 < newMaxLoadFactor
.
|
inline |
Return a theoretical upper bound on the largest number of elements that this unordered map could possibly hold. Note that there is no guarantee that the unordered map can successfully grow to the returned size, or even close to that size, without running out of resources.
|
inline |
Assign to this object the value, hasher, key-equality functor, and max_load_factor
of the specified rhs
object, propagate to this object the allocator of rhs
if the ALLOCATOR
type has trait propagate_on_container_copy_assignment
, and return a reference providing modifiable access to this object. Note that this method requires that the (template parameter) types KEY
and VALUE
both be copy-constructible
(see {Requirements on value_type
}).
|
inline |
Return a reference providing modifiable access to the mapped-value associated with the specified key
in this unordered map; if this unordered map does not already contain a value_type
object with key
, first insert a new value_type
object having key
and a default-constructed VALUE
object. Note that this method requires that the (template parameter) VALUE
is "default-constructible" (see {Requirements on value_type
}). Note that key
may be modified; it is guaranteed to be left in a valid state.
|
inline |
Assign to this object the value, hash function, and key-equality comparator of the specified rhs
object, propagate to this object the allocator of rhs
if the ALLOCATOR
type has trait propagate_on_container_move_assignment
, and return a reference providing modifiable access to this object. The contents of rhs
are moved (in constant time) to this unordered map if get_allocator() == rhs.get_allocator()
(after accounting for the aforementioned trait); otherwise, all elements in this container are either destroyed or move-assigned to, and each additional element in rhs
is move-inserted into this unordered_map. rhs
is left in a valid but unspecified state, and if an exception is thrown, *this
is left in a valid but unspecified state. This method requires that the type value_type
be move-constructible
(see {Requirements on value_type
}). Return a reference providing modifiable access to the mapped-value associated with the specified key
in this unordered map; if this unordered map does not already contain a value_type
object with key
, first insert a new value_type
object having key
and a default-constructed VALUE
object. Note that this method requires that the (template parameter) type KEY
is copy-constructible
and the (template parameter) VALUE
is "default-constructible" (see {Requirements on value_type
}).
|
inline |
Change the size of the array of buckets maintained by this unordered map to at least the specified numBuckets
, and redistribute all the contained elements into the new sequence of buckets, according to their hash values. After this call, load_factor will be less than or equal to max_load_factor
. This operation has no effect if rehashing the elements into numBuckets
would cause this map to exceed its max_load_factor
.
|
inline |
Increase the number of buckets of this set to a quantity such that the ratio between the specified numElements
and this quantity does not exceed max_load_factor
. Note that this guarantees that, after the reserve, elements can be inserted to grow the container to size() == numElements
without rehashing. Also note that memory allocations may still occur when growing the container to size() == numElements
. Also note that this operation has no effect if numElements <= size()
.
|
inline |
pair< iterator, bool > bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::try_emplace | ( | BloombergLP::bslmf::MovableRef< KEY > | key, |
Args &&... | args | ||
) |
If a key equivalent to the specified key
already exists in this unordered_map, return a pair containing an iterator referring to the existing item and false
. Otherwise, insert into this map a newly-created value_type
object, constructed from std::forward<KEY>(key)
and the specified args
, and return a pair containing an iterator referring to the newly-created entry, and true
. This method requires that the (template parameter) types KEY
and VALUE
are emplace-constructible
from key
and args
respectively. For C++03, VALUE
must also be copy-constructible
.
|
inline |
|
inline |
iterator bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::try_emplace | ( | const_iterator | hint, |
BloombergLP::bslmf::MovableRef< KEY > | key, | ||
Args &&... | args | ||
) |
If a key equivalent to the specified key
already exists in this unordered_map, return an iterator referring to the existing item. Otherwise, insert into this map a newly-created value_type
object, constructed from std::forward<KEY>(key)
and the specified args
, and return an iterator referring to the newly-created entry. Use the specified hint
as a starting point for checking to see if the key already in the unordered_map. This method requires that the (template parameter) types KEY
and VALUE
are emplace-constructible
from key
and args
respectively. For C++03, VALUE
must also be copy-constructible
.
|
inline |
iterator bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::try_emplace | ( | const_iterator | hint, |
const KEY & | key, | ||
Args &&... | args | ||
) |
If a key equivalent to the specified key
already exists in this unordered_map, return an iterator referring to the existing item. Otherwise, insert into this map a newly-created value_type
object, constructed from key
and the specified args
, and return an iterator referring to the newly-created entry. Use the specified hint
as a starting point for checking to see if the key already in the unordered_map. This method requires that the (template parameter) types KEY
and VALUE
are emplace-constructible
from key
and args
respectively. For C++03, VALUE
must also be copy-constructible
.
|
inline |
|
inline |
If a key equivalent to the specified key
already exists in this unordered_map, return an iterator referring to the existing item. Otherwise, insert into this map a newly-created value_type
object, constructed from std::forward<LOOKUP_KEY>(key)
and the specified args
, and return an iterator referring to the newly-created entry. Use the specified hint
as a starting point for checking to see if the key already in the unordered_map. This method requires that the (template parameter) types KEY
and VALUE
are emplace-constructible
from key
and args
respectively. For C++03, VALUE
must also be copy-constructible
.
Note: implemented inline due to Sun CC compilation error.
|
inline |
If a key equivalent to the specified key
already exists in this unordered_map, return a pair containing an iterator referring to the existing item and false
. Otherwise, insert into this map a newly-created value_type
object, constructed from std::forward<LOOKUP_KEY>(key)
and the specified args
, and return a pair containing an iterator referring to the newly-created entry, and true
. This method requires that the (template parameter) types KEY
and VALUE
are emplace-constructible
from key
and args
respectively. For C++03, VALUE
must also be copy-constructible
.
Note: implemented inline due to Sun CC compilation error.
|
friend |
void swap(unordered_map &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits pair< iterator, bool > bsl::unordered_map< KEY, VALUE, HASH, EQUAL, ALLOCATOR >::try_emplace(const KEY &key, Args &&... args) |
Exchange the value, hasher, key-equality functor, and max_load_factor
of this object with those of the specified other
object; also exchange the allocator of this object with that of other
if the (template parameter) type ALLOCATOR
has the propagate_on_container_swap
trait, and do not modify either allocator otherwise. This method provides the no-throw exception-safety guarantee if and only if both the (template parameter) types HASH
and EQUAL
provide no-throw swap operations; if an exception is thrown, both objects are left in valid but unspecified states. This operation guarantees O[1]
complexity. The behavior is undefined unless either this object was created with the same allocator as other
or ALLOCATOR
has the propagate_on_container_swap
trait. If a key equivalent to the specified key
already exists in this unordered_map, return a pair containing an iterator referring to the existing item, and false
. Otherwise, insert into this map a newly-created value_type
object, constructed from key
and the specified args
, and return a pair containing an iterator referring to the newly-created entry and true
. This method requires that the (template parameter) types KEY
and VALUE
are emplace-constructible
from key
and args
respectively. For C++03, VALUE
must also be copy-constructible
.