CppCommon  1.0.4.1
C++ Common Library
Public Types | Public Member Functions | Friends | List of all members
CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator > Class Template Reference

Hash map container. More...

#include <hashmap.h>

Public Types

typedef TKey key_type
 
typedef TValue mapped_type
 
typedef std::pair< TKey, TValue > value_type
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef value_typepointer
 
typedef const value_typeconst_pointer
 
typedef ptrdiff_t difference_type
 
typedef size_t size_type
 
typedef HashMapIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue > iterator
 
typedef HashMapConstIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue > const_iterator
 
typedef HashMapReverseIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue > reverse_iterator
 
typedef HashMapConstReverseIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue > const_reverse_iterator
 

Public Member Functions

 HashMap (size_t capacity=128, const TKey &blank=TKey(), const THash &hash=THash(), const TEqual &equal=TEqual(), const TAllocator &allocator=TAllocator())
 Initialize the hash map with a given capacity and blank key value. More...
 
template<class InputIterator >
 HashMap (InputIterator first, InputIterator last, bool unused, size_t capacity=128, const TKey &blank=TKey(), const THash &hash=THash(), const TEqual &equal=TEqual(), const TAllocator &allocator=TAllocator())
 
 HashMap (const HashMap &hashmap)
 
 HashMap (const HashMap &hashmap, size_t capacity)
 
 HashMap (HashMap &&)=default
 
 ~HashMap ()=default
 
HashMapoperator= (const HashMap &hashmap)
 
HashMapoperator= (HashMap &&)=default
 
 operator bool () const noexcept
 Check if the hash map is not empty. More...
 
mapped_typeoperator[] (const TKey &key)
 Access to the item with the given key or insert a new one. More...
 
bool empty () const noexcept
 Is the hash map empty? More...
 
size_t size () const noexcept
 Get the hash map size. More...
 
size_t max_size () const noexcept
 Get the hash map maximum size. More...
 
size_t bucket_count () const noexcept
 Get the hash map bucket count. More...
 
size_t max_bucket_count () const noexcept
 Get the hash map maximum bucket count. More...
 
size_t key_hash (const TKey &key) const noexcept
 Calculate hash of the given key. More...
 
bool key_equal (const TKey &key1, const TKey &key2) const noexcept
 Compare two keys: if the first key equals to the second one? More...
 
iterator begin () noexcept
 Get the begin hash map iterator. More...
 
const_iterator begin () const noexcept
 
const_iterator cbegin () const noexcept
 
iterator end () noexcept
 Get the end hash map iterator. More...
 
const_iterator end () const noexcept
 
const_iterator cend () const noexcept
 
reverse_iterator rbegin () noexcept
 Get the reverse begin hash map iterator. More...
 
const_reverse_iterator rbegin () const noexcept
 
const_reverse_iterator crbegin () const noexcept
 
reverse_iterator rend () noexcept
 Get the reverse end hash map iterator. More...
 
const_reverse_iterator rend () const noexcept
 
const_reverse_iterator crend () const noexcept
 
iterator find (const TKey &key) noexcept
 Find the iterator which points to the first item with the given key in the hash map or return end iterator. More...
 
const_iterator find (const TKey &key) const noexcept
 
std::pair< iterator, iteratorequal_range (const TKey &key) noexcept
 Find the bounds of a range that includes all the elements in the hash map with the given key. More...
 
std::pair< const_iterator, const_iteratorequal_range (const TKey &key) const noexcept
 
size_t count (const TKey &key) const noexcept
 Find the count of items with the given key. More...
 
mapped_typeat (const TKey &key) noexcept
 Access to the item with the given key or throw std::out_of_range exception. More...
 
const mapped_typeat (const TKey &key) const noexcept
 Access to the constant item with the given key or throw std::out_of_range exception. More...
 
std::pair< iterator, bool > insert (const value_type &item)
 Insert a new item into the hash map. More...
 
std::pair< iterator, bool > insert (value_type &&item)
 Insert a new item into the hash map. More...
 
template<typename... Args>
std::pair< iterator, bool > emplace (Args &&... args)
 Emplace a new item into the hash map. More...
 
size_t erase (const TKey &key)
 Erase the item with the given key from the hash map. More...
 
void erase (const const_iterator &position)
 Erase the item by its iterator from the hash map. More...
 
void rehash (size_t capacity)
 Rehash the hash map to the given capacity or more. More...
 
void reserve (size_t count)
 Reserve the hash map capacity to fit the given count of items. More...
 
void clear () noexcept
 Clear the hash map. More...
 
void swap (HashMap &hashmap) noexcept
 Swap two instances. More...
 
template<typename... Args>
std::pair< typename HashMap< TKey, TValue, THash, TEqual, TAllocator >::iterator, bool > emplace (Args &&... args)
 
template<typename... Args>
std::pair< typename HashMap< TKey, TValue, THash, TEqual, TAllocator >::iterator, bool > emplace_internal (const TKey &key, Args &&... args)
 

Friends

class HashMapIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >
 
class HashMapConstIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >
 
class HashMapReverseIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >
 
class HashMapConstReverseIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >
 
template<typename UKey , typename UValue , typename UHash , typename UEqual , typename UAllocator >
void swap (HashMap< UKey, UValue, UHash, UEqual, UAllocator > &hashmap1, HashMap< UKey, UValue, UHash, UEqual, UAllocator > &hashmap2) noexcept
 

Detailed Description

template<typename TKey, typename TValue, typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
class CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >

Hash map container.

Hash map is an efficient structure for associative keys/value storing and accessing without keeping order. It uses hash function to convert string key into the integer and use the index to quick access value data.

Open address hash map resolves collisions of the same hash values by inserting new item into the next free place (probing with step 1).

Not thread-safe.

Examples
containers_hashmap.cpp.

Definition at line 44 of file hashmap.h.

Member Typedef Documentation

◆ const_iterator

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef HashMapConstIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue> CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_iterator

Definition at line 63 of file hashmap.h.

◆ const_pointer

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef const value_type* CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_pointer

Definition at line 59 of file hashmap.h.

◆ const_reference

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef const value_type& CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_reference

Definition at line 57 of file hashmap.h.

◆ const_reverse_iterator

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef HashMapConstReverseIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue> CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_reverse_iterator

Definition at line 65 of file hashmap.h.

◆ difference_type

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef ptrdiff_t CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::difference_type

Definition at line 60 of file hashmap.h.

◆ iterator

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef HashMapIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue> CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::iterator

Definition at line 62 of file hashmap.h.

◆ key_type

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef TKey CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::key_type

Definition at line 53 of file hashmap.h.

◆ mapped_type

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef TValue CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::mapped_type

Definition at line 54 of file hashmap.h.

◆ pointer

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef value_type* CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::pointer

Definition at line 58 of file hashmap.h.

◆ reference

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef value_type& CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::reference

Definition at line 56 of file hashmap.h.

◆ reverse_iterator

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef HashMapReverseIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue> CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::reverse_iterator

Definition at line 64 of file hashmap.h.

◆ size_type

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef size_t CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::size_type

Definition at line 61 of file hashmap.h.

◆ value_type

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
typedef std::pair<TKey, TValue> CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::value_type

Definition at line 55 of file hashmap.h.

Constructor & Destructor Documentation

◆ HashMap() [1/5]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::HashMap ( size_t  capacity = 128,
const TKey &  blank = TKey(),
const THash &  hash = THash(),
const TEqual &  equal = TEqual(),
const TAllocator &  allocator = TAllocator() 
)
inlineexplicit

Initialize the hash map with a given capacity and blank key value.

Parameters
capacity- Hash map capacity (default is 128)
blank- Blank key value (default is TKey())
hash- Key hasher (default is THash())
equal- Key comparator (default is THash())
allocator- Allocator (default is TAllocator())

Definition at line 12 of file hashmap.inl.

◆ HashMap() [2/5]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
template<class InputIterator >
CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::HashMap ( InputIterator  first,
InputIterator  last,
bool  unused,
size_t  capacity = 128,
const TKey &  blank = TKey(),
const THash &  hash = THash(),
const TEqual &  equal = TEqual(),
const TAllocator &  allocator = TAllocator() 
)
inline

Definition at line 23 of file hashmap.inl.

◆ HashMap() [3/5]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::HashMap ( const HashMap< TKey, TValue, THash, TEqual, TAllocator > &  hashmap)
inline

Definition at line 31 of file hashmap.inl.

◆ HashMap() [4/5]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::HashMap ( const HashMap< TKey, TValue, THash, TEqual, TAllocator > &  hashmap,
size_t  capacity 
)
inline

Definition at line 39 of file hashmap.inl.

◆ HashMap() [5/5]

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::HashMap ( HashMap< TKey, TValue, THash, TEqual, TAllocator > &&  )
default

◆ ~HashMap()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::~HashMap ( )
default

Member Function Documentation

◆ at() [1/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
const HashMap< TKey, TValue, THash, TEqual, TAllocator >::mapped_type & CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::at ( const TKey &  key) const
inlinenoexcept

Access to the constant item with the given key or throw std::out_of_range exception.

Parameters
key- Key of the item
Returns
Constant item with the given key

Definition at line 179 of file hashmap.inl.

◆ at() [2/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::mapped_type & CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::at ( const TKey &  key)
inlinenoexcept

Access to the item with the given key or throw std::out_of_range exception.

Parameters
key- Key of the item
Returns
Item with the given key

Definition at line 169 of file hashmap.inl.

◆ begin() [1/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::begin
inlinenoexcept

Definition at line 63 of file hashmap.inl.

◆ begin() [2/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::begin
inlinenoexcept

Get the begin hash map iterator.

Definition at line 57 of file hashmap.inl.

◆ bucket_count()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
size_t CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::bucket_count ( ) const
inlinenoexcept

Get the hash map bucket count.

Definition at line 100 of file hashmap.h.

◆ cbegin()

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::cbegin
inlinenoexcept

Definition at line 69 of file hashmap.inl.

◆ cend()

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::cend
inlinenoexcept

Definition at line 87 of file hashmap.inl.

◆ clear()

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
void CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::clear
inlinenoexcept

Clear the hash map.

Definition at line 306 of file hashmap.inl.

◆ count()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
size_t CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::count ( const TKey &  key) const
inlinenoexcept

Find the count of items with the given key.

Definition at line 136 of file hashmap.h.

◆ crbegin()

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_reverse_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::crbegin
inlinenoexcept

Definition at line 105 of file hashmap.inl.

◆ crend()

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_reverse_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::crend
inlinenoexcept

Definition at line 123 of file hashmap.inl.

◆ emplace() [1/2]

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
template<typename... Args>
std::pair<iterator, bool> CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::emplace ( Args &&...  args)

Emplace a new item into the hash map.

Parameters
args- Arguments to emplace
Returns
Pair with the iterator to the given key and success flag

◆ emplace() [2/2]

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
template<typename... Args>
std::pair<typename HashMap<TKey, TValue, THash, TEqual, TAllocator>::iterator, bool> CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::emplace ( Args &&...  args)
inline

Definition at line 202 of file hashmap.inl.

◆ emplace_internal()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
template<typename... Args>
std::pair<typename HashMap<TKey, TValue, THash, TEqual, TAllocator>::iterator, bool> CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::emplace_internal ( const TKey &  key,
Args &&...  args 
)
inline

Definition at line 226 of file hashmap.inl.

◆ empty()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
bool CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::empty ( ) const
inlinenoexcept

Is the hash map empty?

Definition at line 93 of file hashmap.h.

◆ end() [1/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::end
inlinenoexcept

Definition at line 81 of file hashmap.inl.

◆ end() [2/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::end
inlinenoexcept

Get the end hash map iterator.

Definition at line 75 of file hashmap.inl.

◆ equal_range() [1/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
std::pair< typename HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_iterator, typename HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_iterator > CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::equal_range ( const TKey &  key) const
inlinenoexcept

Definition at line 163 of file hashmap.inl.

◆ equal_range() [2/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
std::pair< typename HashMap< TKey, TValue, THash, TEqual, TAllocator >::iterator, typename HashMap< TKey, TValue, THash, TEqual, TAllocator >::iterator > CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::equal_range ( const TKey &  key)
inlinenoexcept

Find the bounds of a range that includes all the elements in the hash map with the given key.

Definition at line 157 of file hashmap.inl.

◆ erase() [1/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
void CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::erase ( const const_iterator position)
inline

Erase the item by its iterator from the hash map.

Parameters
position- Iterator position to the erased item

Definition at line 219 of file hashmap.inl.

◆ erase() [2/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
size_t CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::erase ( const TKey &  key)
inline

Erase the item with the given key from the hash map.

Parameters
key- Key of the item to erase
Returns
Number of erased elements (0 or 1 for the hash map)

Definition at line 208 of file hashmap.inl.

◆ find() [1/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::find ( const TKey &  key) const
inlinenoexcept

Definition at line 143 of file hashmap.inl.

◆ find() [2/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::find ( const TKey &  key)
inlinenoexcept

Find the iterator which points to the first item with the given key in the hash map or return end iterator.

Definition at line 129 of file hashmap.inl.

◆ insert() [1/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
std::pair< typename HashMap< TKey, TValue, THash, TEqual, TAllocator >::iterator, bool > CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::insert ( const value_type item)
inline

Insert a new item into the hash map.

Parameters
item- Item to insert as a key/value pair
Returns
Pair with the iterator to the given key and success flag

Definition at line 189 of file hashmap.inl.

◆ insert() [2/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
std::pair< typename HashMap< TKey, TValue, THash, TEqual, TAllocator >::iterator, bool > CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::insert ( value_type &&  item)
inline

Insert a new item into the hash map.

Parameters
item- Item to insert as a key/value pair
Returns
Pair with the iterator to the given key and success flag

Definition at line 195 of file hashmap.inl.

◆ key_equal()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
bool CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::key_equal ( const TKey &  key1,
const TKey &  key2 
) const
inlinenoexcept

Compare two keys: if the first key equals to the second one?

Definition at line 107 of file hashmap.h.

◆ key_hash()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
size_t CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::key_hash ( const TKey &  key) const
inlinenoexcept

Calculate hash of the given key.

Definition at line 105 of file hashmap.h.

◆ max_bucket_count()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
size_t CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::max_bucket_count ( ) const
inlinenoexcept

Get the hash map maximum bucket count.

Definition at line 102 of file hashmap.h.

◆ max_size()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
size_t CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::max_size ( ) const
inlinenoexcept

Get the hash map maximum size.

Definition at line 98 of file hashmap.h.

◆ operator bool()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::operator bool ( ) const
inlineexplicitnoexcept

Check if the hash map is not empty.

Definition at line 87 of file hashmap.h.

◆ operator=() [1/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator > & CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::operator= ( const HashMap< TKey, TValue, THash, TEqual, TAllocator > &  hashmap)
inline

Definition at line 47 of file hashmap.inl.

◆ operator=() [2/2]

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
HashMap& CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::operator= ( HashMap< TKey, TValue, THash, TEqual, TAllocator > &&  )
default

◆ operator[]()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
mapped_type& CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::operator[] ( const TKey &  key)
inline

Access to the item with the given key or insert a new one.

Definition at line 90 of file hashmap.h.

◆ rbegin() [1/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_reverse_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::rbegin
inlinenoexcept

Definition at line 99 of file hashmap.inl.

◆ rbegin() [2/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::reverse_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::rbegin
inlinenoexcept

Get the reverse begin hash map iterator.

Definition at line 93 of file hashmap.inl.

◆ rehash()

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
void CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::rehash ( size_t  capacity)
inline

Rehash the hash map to the given capacity or more.

Parameters
capacity- Hash map capacity

Definition at line 291 of file hashmap.inl.

◆ rend() [1/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::const_reverse_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::rend
inlinenoexcept

Definition at line 117 of file hashmap.inl.

◆ rend() [2/2]

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
HashMap< TKey, TValue, THash, TEqual, TAllocator >::reverse_iterator CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::rend
inlinenoexcept

Get the reverse end hash map iterator.

Definition at line 111 of file hashmap.inl.

◆ reserve()

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
void CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::reserve ( size_t  count)
inline

Reserve the hash map capacity to fit the given count of items.

Parameters
count- Count of items to fit

Definition at line 299 of file hashmap.inl.

◆ size()

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
size_t CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::size ( ) const
inlinenoexcept

Get the hash map size.

Definition at line 96 of file hashmap.h.

◆ swap()

template<typename TKey , typename TValue , typename THash , typename TEqual , typename TAllocator >
void CppCommon::HashMap< TKey, TValue, THash, TEqual, TAllocator >::swap ( HashMap< TKey, TValue, THash, TEqual, TAllocator > &  hashmap)
inlinenoexcept

Swap two instances.

Definition at line 314 of file hashmap.inl.

Friends And Related Function Documentation

◆ HashMapConstIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
friend class HashMapConstIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >
friend

Definition at line 1 of file hashmap.h.

◆ HashMapConstReverseIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
friend class HashMapConstReverseIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >
friend

Definition at line 1 of file hashmap.h.

◆ HashMapIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
friend class HashMapIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >
friend

Definition at line 1 of file hashmap.h.

◆ HashMapReverseIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
friend class HashMapReverseIterator< HashMap< TKey, TValue, THash, TEqual, TAllocator >, TKey, TValue >
friend

Definition at line 1 of file hashmap.h.

◆ swap

template<typename TKey , typename TValue , typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
template<typename UKey , typename UValue , typename UHash , typename UEqual , typename UAllocator >
void swap ( HashMap< UKey, UValue, UHash, UEqual, UAllocator > &  hashmap1,
HashMap< UKey, UValue, UHash, UEqual, UAllocator > &  hashmap2 
)
friend

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