Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Public Types | Public Member Functions
ext::unordered_map< T, R, Hash, KeyEqual, Alloc > Class Template Reference

Class extending the unordered_map class from the standard library. Original reason is to allow printing of the container with overloaded operator <<. More...

#include <unordered_map.hpp>

Inheritance diagram for ext::unordered_map< T, R, Hash, KeyEqual, Alloc >:
[legend]
Collaboration diagram for ext::unordered_map< T, R, Hash, KeyEqual, Alloc >:
[legend]

Public Types

using iterator = typename std::unordered_map< T, R, Hash, KeyEqual, Alloc >::iterator
 The iterator type is inheried. More...
 

Public Member Functions

 unordered_map ()=default
 
 unordered_map (const unordered_map &other)=default
 
 unordered_map (unordered_map &&other)=default
 
unordered_mapoperator= (unordered_map &&other)=default
 
unordered_mapoperator= (const unordered_map &other)=default
 
template<class Iterator >
 unordered_map (const ext::iterator_range< Iterator > &range)
 
std::pair< iterator, bool > insert (const T &key, const R &value)
 Insert variant with explicit key and value parameters. More...
 
std::pair< iterator, bool > insert (const T &key, R &&value)
 Insert variant with explicit key and value parameters. More...
 
std::pair< iterator, bool > insert (T &&key, const R &value)
 Insert variant with explicit key and value parameters. More...
 
std::pair< iterator, bool > insert (T &&key, R &&value)
 Insert variant with explicit key and value parameters. More...
 
auto begin () &
 Inherited behavior of begin for non-const instance. More...
 
auto begin () const &
 Inherited behavior of begin for const instance. More...
 
auto begin () &&
 New variant of begin for rvalues. More...
 
auto end () &
 Inherited behavior of end for non-const instance. More...
 
auto end () const &
 Inherited behavior of end for const instance. More...
 
auto end () &&
 New variant of end for rvalues. More...
 
auto range () &
 Make range of non-const begin to end iterators. More...
 
auto range () const &
 Make range of non-const begin to end iterators. More...
 
auto range () &&
 Make range of move begin to end iterators. More...
 

Detailed Description

template<class T, class R, class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
class ext::unordered_map< T, R, Hash, KeyEqual, Alloc >

Class extending the unordered_map class from the standard library. Original reason is to allow printing of the container with overloaded operator <<.

The class mimics the behavior of the unordered_map from the standatd library.

Template Parameters
Tthe type of keys inside the unordered_map
Rthe type of values inside the unordered_map
Hashthe hasher type used to order keys
KeyEqualthe comparator of keys
Allocthe allocator of values of type T

Member Typedef Documentation

◆ iterator

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
using ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::iterator = typename std::unordered_map<T, R, Hash, KeyEqual, Alloc>::iterator

The iterator type is inheried.

Constructor & Destructor Documentation

◆ unordered_map() [1/4]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::unordered_map ( )
default

Default constructor needed by g++ since it is not inherited

◆ unordered_map() [2/4]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::unordered_map ( const unordered_map< T, R, Hash, KeyEqual, Alloc > &  other)
default

Copy constructor needed by g++ since it is not inherited

◆ unordered_map() [3/4]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::unordered_map ( unordered_map< T, R, Hash, KeyEqual, Alloc > &&  other)
default

Move constructor needed by g++ since it is not inherited

◆ unordered_map() [4/4]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
template<class Iterator >
ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::unordered_map ( const ext::iterator_range< Iterator > &  range)
inline

Constructor from range of values.

Template Parameters
Iteratorthe type of range iterator
Parameters
rangethe source range

Member Function Documentation

◆ begin() [1/3]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
auto ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::begin ( ) &
inline

Inherited behavior of begin for non-const instance.

Returns
iterator the first element of unordered_map
Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin() [2/3]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
auto ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::begin ( ) &&
inline

New variant of begin for rvalues.

Returns
move_iterator the first element of unordered_map
Here is the call graph for this function:

◆ begin() [3/3]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
auto ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::begin ( ) const &
inline

Inherited behavior of begin for const instance.

Returns
const_iterator the first element of unordered_map
Here is the call graph for this function:

◆ end() [1/3]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
auto ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::end ( ) &
inline

Inherited behavior of end for non-const instance.

Returns
iterator to one after the last element of unordered_map
Here is the call graph for this function:
Here is the caller graph for this function:

◆ end() [2/3]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
auto ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::end ( ) &&
inline

New variant of end for rvalues.

Returns
move_iterator to one after the last element of unordered_map
Here is the call graph for this function:

◆ end() [3/3]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
auto ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::end ( ) const &
inline

Inherited behavior of end for const instance.

Returns
const_iterator to one after the last element of unordered_map
Here is the call graph for this function:

◆ insert() [1/4]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
std::pair< iterator, bool > ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::insert ( const T &  key,
const R &  value 
)
inline

Insert variant with explicit key and value parameters.

Parameters
keythe key
valuethe value
Returns
pair of iterator to inserted key-value pair and true if the value was inserted or false if the key already exited
Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert() [2/4]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
std::pair< iterator, bool > ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::insert ( const T &  key,
R &&  value 
)
inline

Insert variant with explicit key and value parameters.

Parameters
keythe key
valuethe value
Returns
pair of iterator to inserted key-value pair and true if the value was inserted or false if the key already exited
Here is the call graph for this function:

◆ insert() [3/4]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
std::pair< iterator, bool > ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::insert ( T &&  key,
const R &  value 
)
inline

Insert variant with explicit key and value parameters.

Parameters
keythe key
valuethe value
Returns
pair of iterator to inserted key-value pair and true if the value was inserted or false if the key already exited
Here is the call graph for this function:

◆ insert() [4/4]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
std::pair< iterator, bool > ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::insert ( T &&  key,
R &&  value 
)
inline

Insert variant with explicit key and value parameters.

Parameters
keythe key
valuethe value
Returns
pair of iterator to inserted key-value pair and true if the value was inserted or false if the key already exited
Here is the call graph for this function:

◆ operator=() [1/2]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
unordered_map & ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::operator= ( const unordered_map< T, R, Hash, KeyEqual, Alloc > &  other)
default

Move operator = needed by g++ since it is not inherited

◆ operator=() [2/2]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
unordered_map & ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::operator= ( unordered_map< T, R, Hash, KeyEqual, Alloc > &&  other)
default

Copy operator = needed by g++ since it is not inherited

◆ range() [1/3]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
auto ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::range ( ) &
inline

Make range of non-const begin to end iterators.

Returns
full range over container values
Here is the call graph for this function:

◆ range() [2/3]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
auto ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::range ( ) &&
inline

Make range of move begin to end iterators.

Returns
full range over container values

◆ range() [3/3]

template<class T , class R , class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > >>
auto ext::unordered_map< T, R, Hash, KeyEqual, Alloc >::range ( ) const &
inline

Make range of non-const begin to end iterators.

Returns
full range over container values
Here is the call graph for this function:

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