BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL > Class Template Reference

#include <bdlc_flathashmap.h>

Public Types

typedef bsl::pair< typename bsl::add_const< KEY >::type, VALUE > value_type
 
typedef KEY key_type
 
typedef VALUE mapped_type
 
typedef bsl::size_t size_type
 
typedef bsl::ptrdiff_t difference_type
 
typedef EQUAL key_compare
 
typedef HASH hasher
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef value_typepointer
 
typedef const value_typeconst_pointer
 
typedef ImplType::iterator iterator
 
typedef ImplType::const_iterator const_iterator
 

Public Member Functions

 FlatHashMap ()
 
 FlatHashMap (bslma::Allocator *basicAllocator)
 
 FlatHashMap (bsl::size_t capacity)
 
 FlatHashMap (bsl::size_t capacity, bslma::Allocator *basicAllocator)
 
 FlatHashMap (bsl::size_t capacity, const HASH &hash, bslma::Allocator *basicAllocator=0)
 
 FlatHashMap (bsl::size_t capacity, const HASH &hash, const EQUAL &equal, bslma::Allocator *basicAllocator=0)
 
template<class INPUT_ITERATOR >
 FlatHashMap (INPUT_ITERATOR first, INPUT_ITERATOR last, bslma::Allocator *basicAllocator=0)
 
template<class INPUT_ITERATOR >
 FlatHashMap (INPUT_ITERATOR first, INPUT_ITERATOR last, bsl::size_t capacity, bslma::Allocator *basicAllocator=0)
 
template<class INPUT_ITERATOR >
 FlatHashMap (INPUT_ITERATOR first, INPUT_ITERATOR last, bsl::size_t capacity, const HASH &hash, bslma::Allocator *basicAllocator=0)
 
template<class INPUT_ITERATOR >
 FlatHashMap (INPUT_ITERATOR first, INPUT_ITERATOR last, bsl::size_t capacity, const HASH &hash, const EQUAL &equal, bslma::Allocator *basicAllocator=0)
 
 FlatHashMap (const FlatHashMap &original, bslma::Allocator *basicAllocator=0)
 
 FlatHashMap (bslmf::MovableRef< FlatHashMap > original)
 
 FlatHashMap (bslmf::MovableRef< FlatHashMap > original, bslma::Allocator *basicAllocator)
 
 ~FlatHashMap ()
 Destroy this object and each of its elements.
 
FlatHashMapoperator= (const FlatHashMap &rhs)
 
FlatHashMapoperator= (bslmf::MovableRef< FlatHashMap > rhs)
 
template<class KEY_TYPE >
VALUE & operator[] (BSLS_COMPILERFEATURES_FORWARD_REF(KEY_TYPE) key)
 
VALUE & at (const KEY &key)
 
void clear ()
 
bsl::pair< iterator, iteratorequal_range (const KEY &key)
 
template<class... ARGS>
bsl::pair< iterator, bool > emplace (ARGS &&... args)
 
template<class... ARGS>
iterator emplace_hint (const_iterator hint, ARGS &&... args)
 
bsl::size_t erase (const KEY &key)
 
iterator erase (const_iterator position)
 
iterator erase (iterator position)
 
iterator erase (const_iterator first, const_iterator last)
 
iterator find (const KEY &key)
 
template<class VALUE_TYPE >
bsl::enable_if< bsl::is_convertible< VALUE_TYPE, value_type >::value, bsl::pair< iterator, bool > >::type insert (BSLS_COMPILERFEATURES_FORWARD_REF(VALUE_TYPE) value)
 
template<class VALUE_TYPE >
bsl::enable_if< bsl::is_convertible< VALUE_TYPE, value_type >::value, iterator >::type insert (const_iterator, BSLS_COMPILERFEATURES_FORWARD_REF(VALUE_TYPE) value)
 
template<class INPUT_ITERATOR >
void insert (INPUT_ITERATOR first, INPUT_ITERATOR last)
 
void rehash (bsl::size_t minimumCapacity)
 
void reserve (bsl::size_t numEntries)
 
void reset ()
 
iterator begin ()
 
iterator end ()
 
void swap (FlatHashMap &other)
 
const VALUE & at (const KEY &key) const
 
bsl::size_t capacity () const
 
bool contains (const KEY &key) const
 
bsl::size_t count (const KEY &key) const
 
bool empty () const
 
bsl::pair< const_iterator, const_iteratorequal_range (const KEY &key) const
 
const_iterator find (const KEY &key) const
 
HASH hash_function () const
 
EQUAL key_eq () const
 
float load_factor () const
 
float max_load_factor () const
 
bsl::size_t size () const
 Return the number of elements in this map.
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
const_iterator end () const
 
bslma::Allocatorallocator () const
 Return the allocator used by this flat hash map to supply memory.
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 
template<class... ARGS>
bsl::pair< typename FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator, bool > emplace (ARGS &&... args)
 

Friends

bool operator== (const FlatHashMap &, const FlatHashMap &)
 
bool operator!= (const FlatHashMap &, const FlatHashMap &)
 
template<class K , class V , class H , class E >
void swap (FlatHashMap< K, V, H, E > &, FlatHashMap< K, V, H, E > &)
 

Detailed Description

template<class KEY, class VALUE, class HASH, class EQUAL>
class bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >

This class template implements a value-semantic container type holding an unordered map of KEY-VALUE pairs having unique keys that provides a mapping from keys of (template parameter) type KEY to their associated mapped values of (template parameter) type VALUE. The (template parameter) type HASH is a functor providing the hash value for KEY. The (template parameter) type EQUAL is a functor providing the equality function for two KEY values. See {Requirements on KEY, HASH, and EQUAL} for more information.

See bdlc_flathashmap

Member Typedef Documentation

◆ const_iterator

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef ImplType::const_iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::const_iterator

◆ const_pointer

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef const value_type* bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::const_pointer

◆ const_reference

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef const value_type& bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::const_reference

◆ difference_type

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef bsl::ptrdiff_t bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::difference_type

◆ hasher

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef HASH bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::hasher

◆ iterator

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef ImplType::iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator

◆ key_compare

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef EQUAL bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::key_compare

◆ key_type

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef KEY bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::key_type

◆ mapped_type

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef VALUE bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::mapped_type

◆ pointer

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef value_type* bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::pointer

◆ reference

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef value_type& bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::reference

◆ size_type

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef bsl::size_t bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::size_type

◆ value_type

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef bsl::pair<typename bsl::add_const<KEY>::type, VALUE> bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::value_type

Constructor & Destructor Documentation

◆ FlatHashMap() [1/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( )
inline

◆ FlatHashMap() [2/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( bslma::Allocator basicAllocator)
inlineexplicit

◆ FlatHashMap() [3/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( bsl::size_t  capacity)
inlineexplicit

◆ FlatHashMap() [4/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( bsl::size_t  capacity,
bslma::Allocator basicAllocator 
)
inline

◆ FlatHashMap() [5/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( bsl::size_t  capacity,
const HASH &  hash,
bslma::Allocator basicAllocator = 0 
)
inline

◆ FlatHashMap() [6/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( bsl::size_t  capacity,
const HASH &  hash,
const EQUAL &  equal,
bslma::Allocator basicAllocator = 0 
)
inline

Create an empty FlatHashMap object. Optionally specify a capacity indicating the minimum initial size of the underlying array of entries of this container. If capacity is not supplied or is 0, no memory is allocated. Optionally specify a hash functor used to generate the hash values associated with the keys of elements in this container. If hash is not supplied, a default-constructed object of the (template parameter) type HASH is used. Optionally specify an equality functor equal used to determine whether the keys of two elements are equivalent. If equal 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 or is 0, the currently installed default allocator is used.

◆ FlatHashMap() [7/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class INPUT_ITERATOR >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last,
bslma::Allocator basicAllocator = 0 
)
inline

Create a FlatHashMap object initialized by insertion of the values from the input iterator range specified by first through last (including first, excluding last). Optionally specify a capacity indicating the minimum initial size of the underlying array of entries of this container. If capacity is not supplied or is 0, no memory is allocated. Optionally specify a hash functor used to generate hash values associated with the keys of the elements in this container. If hash is not supplied, a default-constructed object of the (template parameter) type HASH is used. Optionally specify an equality functor equal used to determine whether the keys of two elements are equivalent. If equal 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 or is 0, the currently installed default allocator is used. 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 if a member of the input sequence has an equivalent key to an earlier member, the later member will not be inserted.

◆ FlatHashMap() [8/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class INPUT_ITERATOR >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last,
bsl::size_t  capacity,
bslma::Allocator basicAllocator = 0 
)
inline

◆ FlatHashMap() [9/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class INPUT_ITERATOR >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last,
bsl::size_t  capacity,
const HASH &  hash,
bslma::Allocator basicAllocator = 0 
)
inline

◆ FlatHashMap() [10/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class INPUT_ITERATOR >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last,
bsl::size_t  capacity,
const HASH &  hash,
const EQUAL &  equal,
bslma::Allocator basicAllocator = 0 
)
inline

◆ FlatHashMap() [11/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( const FlatHashMap< KEY, VALUE, HASH, EQUAL > &  original,
bslma::Allocator basicAllocator = 0 
)
inline

Create a FlatHashMap object having the same value, hasher, and equality comparator as the specified original object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is not specified or is 0, the currently installed default allocator is used.

◆ FlatHashMap() [12/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( bslmf::MovableRef< FlatHashMap< KEY, VALUE, HASH, EQUAL > >  original)
inline

Create a FlatHashMap object having the same value, hasher, equality comparator, and allocator as the specified original object. The contents of original are moved (in constant time) to this object, original is left in a (valid) unspecified state, and no exceptions will be thrown.

◆ FlatHashMap() [13/13]

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::FlatHashMap ( bslmf::MovableRef< FlatHashMap< KEY, VALUE, HASH, EQUAL > >  original,
bslma::Allocator basicAllocator 
)
inline

Create a FlatHashMap object having the same value, hasher, and equality comparator as the specified original object, using the specified basicAllocator to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The allocator of original remains unchanged. If original and the newly created object have the same allocator then the contents of original are moved (in constant time) to this object, original is left in a (valid) unspecified state, and no exceptions will be thrown; otherwise, original is unchanged (and an exception may be thrown).

◆ ~FlatHashMap()

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::~FlatHashMap ( )
inline

Member Function Documentation

◆ allocator()

template<class KEY , class VALUE , class HASH , class EQUAL >
bslma::Allocator * bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::allocator ( ) const
inline

◆ at() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
VALUE & bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::at ( const KEY &  key)
inline

Return a reference providing modifiable access to the mapped value associated with the specified key in this map, if such an entry exists; otherwise throw a std::out_of_range exception. Note that this method is not exception-neutral.

◆ at() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
const VALUE & bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::at ( const KEY &  key) const
inline

Return a reference providing non-modifiable access to the mapped value associated with the specified key in this map, if such an entry exists; otherwise throw a std::out_of_range exception. Note that this method is not exception-neutral.

◆ begin() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::begin ( )
inline

Return an iterator to the first element in the sequence of modifiable elements maintained by this map, or the end iterator if this map is empty.

◆ begin() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::const_iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::begin ( ) const
inline

Return a const_iterator to the first element in the sequence of elements maintained by this map, or the end iterator if this map is empty.

◆ capacity()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::capacity ( ) const
inline

Return the number of elements this map could hold if the load factor were 1.

◆ cbegin()

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::const_iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::cbegin ( ) const
inline

Return a const_iterator to the first element in the sequence of elements maintained by this map, or the end iterator if this map is empty.

◆ cend()

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::const_iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::cend ( ) const
inline

Return a const_iterator to the past-the-end element in the sequence of elements maintained by this map.

◆ clear()

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::clear ( )
inline

Remove all elements from this map. Note that this map will be empty after calling this method, but allocated memory may be retained for future use. See the capacity method.

◆ contains()

template<class KEY , class VALUE , class HASH , class EQUAL >
bool bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::contains ( const KEY &  key) const
inline

Return true if this map contains an element having the specified key, and false otherwise.

◆ count()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::count ( const KEY &  key) const
inline

Return the number of elements in this map having the specified key. Note that since a flat hash map maintains unique keys, the returned value will be either 0 or 1.

◆ emplace() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class... ARGS>
bsl::pair< iterator, bool > bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::emplace ( ARGS &&...  args)

Insert into this 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}).

◆ emplace() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class... ARGS>
bsl::pair< typename FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator, bool > bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::emplace ( ARGS &&...  args)
inline

◆ emplace_hint()

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class... ARGS>
FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::emplace_hint ( const_iterator  hint,
ARGS &&...  args 
)
inline

Insert into this 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).

◆ empty()

template<class KEY , class VALUE , class HASH , class EQUAL >
bool bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::empty ( ) const
inline

Return true if this map contains no elements, and false otherwise.

◆ end() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::end ( )
inline

Return an iterator to the past-the-end element in the sequence of modifiable elements maintained by this map.

◆ end() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::const_iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::end ( ) const
inline

Return a const_iterator to the past-the-end element in the sequence of elements maintained by this map.

◆ equal_range() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::pair< typename FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator, typename FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator > bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::equal_range ( const KEY &  key)

Return a pair of iterators defining the sequence of modifiable elements in this map having the specified key, where the first iterator is positioned at the start of the sequence and the second iterator is positioned one past the end of the sequence. If this map contains no elements having a key equivalent to key, then the two returned iterators will have the same value. Note that since a map maintains unique keys, the range will contain at most one element.

◆ equal_range() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::pair< typename FlatHashMap< KEY, VALUE, HASH, EQUAL >::const_iterator, typename FlatHashMap< KEY, VALUE, HASH, EQUAL >::const_iterator > bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::equal_range ( const KEY &  key) const

Return a pair of const_iterators defining the sequence of elements in this map having the specified key, where the first iterator is positioned at the start of the sequence and the second iterator is positioned one past the end of the sequence. If this map contains no elements having a key equivalent to key, then the two returned iterators will have the same value. Note that since a map maintains unique keys, the range will contain at most one element.

◆ erase() [1/4]

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::erase ( const KEY &  key)

Remove from this map the element whose key is equal to the specified key, if it exists, and return 1; otherwise (there is no element having key in this map), return 0 with no other effect. This method invalidates all iterators and references to the removed element.

◆ erase() [2/4]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::erase ( const_iterator  first,
const_iterator  last 
)

Remove from this map the elements starting at the specified first position up to, but not including, the specified last position, and return an iterator referencing the same element as last. This method invalidates all iterators and references to the removed elements. The behavior is undefined unless first and last are valid iterators on this map, and the first position is at or before the last position in the iteration sequence provided by this container.

◆ erase() [3/4]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::erase ( const_iterator  position)
inline

◆ erase() [4/4]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::erase ( iterator  position)
inline

Remove from this map the element at the specified position, and return an iterator referring to the modifiable 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 map. This method invalidates all iterators and references to the removed element. The behavior is undefined unless position refers to an element in this map.

◆ find() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::find ( const KEY &  key)
inline

Return an iterator referring to the modifiable element in this map having the specified key, or end() if no such entry exists in this map.

◆ find() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL >::const_iterator bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::find ( const KEY &  key) const
inline

Return a const_iterator referring to the element in this map having the specified key, or end() if no such entry exists in this map.

◆ hash_function()

template<class KEY , class VALUE , class HASH , class EQUAL >
HASH bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::hash_function ( ) const
inline

Return (a copy of) the unary hash functor used by this map to generate a hash value (of type bsl::size_t) for a KEY object.

◆ insert() [1/3]

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class VALUE_TYPE >
bsl::enable_if< bsl::is_convertible< VALUE_TYPE, value_type >::value, bsl::pair< iterator, bool > >::type bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::insert ( BSLS_COMPILERFEATURES_FORWARD_REF(VALUE_TYPE)  value)
inline

◆ insert() [2/3]

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class VALUE_TYPE >
bsl::enable_if< bsl::is_convertible< VALUE_TYPE, value_type >::value, iterator >::type bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::insert ( const_iterator  ,
BSLS_COMPILERFEATURES_FORWARD_REF(VALUE_TYPE)  value 
)
inline

◆ insert() [3/3]

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class INPUT_ITERATOR >
void bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::insert ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last 
)

Insert into this map the value of each element in the input iterator range specified by first through last (including first, excluding last). 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 if the key of a member of the input sequence is equivalent to the key of an earlier member, the later member will not be inserted.

◆ key_eq()

template<class KEY , class VALUE , class HASH , class EQUAL >
EQUAL bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::key_eq ( ) const
inline

Return (a copy of) the binary key-equality functor that returns true if the value of two KEY objects are equivalent, and false otherwise.

◆ load_factor()

template<class KEY , class VALUE , class HASH , class EQUAL >
float bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::load_factor ( ) const
inline

Return the current ratio between the number of elements in this container and its capacity.

◆ max_load_factor()

template<class KEY , class VALUE , class HASH , class EQUAL >
float bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::max_load_factor ( ) const
inline

Return the maximum load factor allowed for this map. Note that if an insert operation would cause the load factor to exceed max_load_factor(), that same insert operation will increase the capacity and rehash the entries of the container (see {Load Factor and Resizing}). Also note that the value returned by max_load_factor is implementation defined and cannot be changed by the user.

◆ operator=() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL > & bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::operator= ( bslmf::MovableRef< FlatHashMap< KEY, VALUE, HASH, EQUAL > >  rhs)
inline

Assign to this object the value, hasher, and equality comparator of the specified rhs object, and return a reference providing modifiable access to this object. If this object and rhs use the same allocator the contents of rhs are moved (in constant time) to this object. rhs is left in a (valid) unspecified state.

◆ operator=() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
FlatHashMap< KEY, VALUE, HASH, EQUAL > & bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::operator= ( const FlatHashMap< KEY, VALUE, HASH, EQUAL > &  rhs)
inline

Assign to this object the value, hasher, and equality functor of the specified rhs object, and return a reference providing modifiable access to this object.

◆ operator[]()

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class KEY_TYPE >
VALUE & bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::operator[] ( BSLS_COMPILERFEATURES_FORWARD_REF(KEY_TYPE)  key)
inline

Return a reference providing modifiable access to the mapped value associated with the specified key in this map. If this map does not already contain an element having key, insert an element with the key and a default-constructed VALUE, and return a reference to the newly mapped value. If key is movable, key is left in a (valid) unspecified state.

◆ print()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::ostream & bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level, and return a reference to the modifiable stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.

◆ rehash()

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::rehash ( bsl::size_t  minimumCapacity)
inline

Change the capacity of this map to at least the specified minimumCapacity, and redistribute all the contained elements into a new sequence of entries according to their hash values. If 0 == minimumCapacity and 0 == size(), the map is returned to the default constructed state. After this call, load_factor() will be less than or equal to max_load_factor() and all iterators, pointers, and references to elements of this map are invalidated.

◆ reserve()

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::reserve ( bsl::size_t  numEntries)
inline

Change the capacity of this map to at least a capacity that can accommodate the specified numEntries (accounting for the load factor invariant), and redistribute all the contained elements into a new sequence of entries according to their hash values. If 0 == numEntries and 0 == size(), the map is returned to the default constructed state. After this call, load_factor() will be less than or equal to max_load_factor() and all iterators, pointers, and references to elements of this map are invalidated. Note that this method is effectively equivalent to:

rehash(bsl::ceil(numEntries / max_load_factor()))
void rehash(bsl::size_t minimumCapacity)
Definition bdlc_flathashmap.h:1493
float max_load_factor() const
Definition bdlc_flathashmap.h:1685

◆ reset()

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::reset ( )
inline

Remove all elements from this map and release all memory from this map, returning the map to the default constructed state.

◆ size()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::size ( ) const
inline

◆ swap()

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlc::FlatHashMap< KEY, VALUE, HASH, EQUAL >::swap ( FlatHashMap< KEY, VALUE, HASH, EQUAL > &  other)
inline

Exchange the value of this object as well as its hasher and equality functors with those of the specified other object. The behavior is undefined unless this object was created with the same allocator as other.

Friends And Related Symbol Documentation

◆ operator!=

template<class KEY , class VALUE , class HASH , class EQUAL >
bool operator!= ( const FlatHashMap< KEY, VALUE, HASH, EQUAL > &  ,
const FlatHashMap< KEY, VALUE, HASH, EQUAL > &   
)
friend

Return true if the specified lhs and rhs objects do not have the same value, and false otherwise. Two FlatHashMap objects do not have the same value if their sizes are different or one contains an element equal to no element of the other. The hash and equality functors are not involved in the comparison.

◆ operator==

template<class KEY , class VALUE , class HASH , class EQUAL >
bool operator== ( const FlatHashMap< KEY, VALUE, HASH, EQUAL > &  ,
const FlatHashMap< KEY, VALUE, HASH, EQUAL > &   
)
friend

Return true if the specified lhs and rhs objects have the same value, and false otherwise. Two FlatHashMap objects have the same value if their sizes are the same and each element contained in one is equal to an element of the other. The hash and equality functors are not involved in the comparison.

◆ swap

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class K , class V , class H , class E >
void swap ( FlatHashMap< K, V, H, E > &  ,
FlatHashMap< K, V, H, E > &   
)
friend

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