SPH
Classes | Public Member Functions | List of all members
UnorderedMap< TKey, TValue > Class Template Reference

#include <UnorderedMap.h>

Inheritance diagram for UnorderedMap< TKey, TValue >:
Noncopyable

Classes

struct  Element
 Element of the container. More...
 

Public Member Functions

 UnorderedMap ()=default
 
 UnorderedMap (std::initializer_list< Element > list)
 Constructs the map fromm initializer list of elements. More...
 
INLINE TValue & operator[] (const TKey &key)
 Returns a reference to the element, given its key. More...
 
INLINE const TValue & operator[] (const TKey &key) const
 Returns a reference to the element, given its key. More...
 
INLINE TValue & insert (const TKey &key, const TValue &value)
 Adds a new element into the map or sets new value of element with the same key. More...
 
INLINE TValue & insert (const TKey &key, TValue &&value)
 Adds a new element into the map or sets new value of element with the same key. More...
 
INLINE void remove (const TKey &key)
 Removes element with given key from the map. More...
 
INLINE bool tryRemove (const TKey &key)
 Removes element with given key if present, otherwise it does nothing. More...
 
INLINE void clear ()
 Removes all elements from the map. More...
 
INLINE Optional< TValue & > tryGet (const TKey &key)
 Returns a reference to the value matching the given key, or NOTHING if no such value exists. More...
 
INLINE Optional< const TValue & > tryGet (const TKey &key) const
 Returns a reference to the value matching the given key, or NOTHING if no such value exists. More...
 
INLINE bool contains (const TKey &key) const
 Returns true if the map contains element of given key. More...
 
INLINE Size size () const
 Returns the number of elements in the map. More...
 
INLINE Size empty () const
 Returns true if the map contains no elements, false otherwise. More...
 
INLINE Iterator< Elementbegin ()
 Returns the iterator pointing to the first element. More...
 
INLINE Iterator< const Elementbegin () const
 Returns the iterator pointing to the first element. More...
 
INLINE Iterator< Elementend ()
 Returns the iterator pointing to the one-past-last element. More...
 
INLINE Iterator< const Elementend () const
 Returns the iterator pointing to the one-past-last element. More...
 
INLINE operator ArrayView< Element > ()
 
INLINE operator ArrayView< const Element > () const
 
UnorderedMap clone () const
 
- Public Member Functions inherited from Noncopyable
 Noncopyable ()=default
 
 Noncopyable (const Noncopyable &)=delete
 
 Noncopyable (Noncopyable &&)=default
 
Noncopyableoperator= (const Noncopyable &)=delete
 
Noncopyableoperator= (Noncopyable &&)=default
 

Detailed Description

template<typename TKey, typename TValue>
class UnorderedMap< TKey, TValue >

Definition at line 14 of file UnorderedMap.h.

Constructor & Destructor Documentation

◆ UnorderedMap() [1/2]

template<typename TKey , typename TValue >
UnorderedMap< TKey, TValue >::UnorderedMap ( )
default

◆ UnorderedMap() [2/2]

template<typename TKey , typename TValue >
UnorderedMap< TKey, TValue >::UnorderedMap ( std::initializer_list< Element list)
inline

Constructs the map fromm initializer list of elements.

Definition at line 29 of file UnorderedMap.h.

Member Function Documentation

◆ begin() [1/2]

template<typename TKey , typename TValue >
INLINE Iterator<Element> UnorderedMap< TKey, TValue >::begin ( )
inline

Returns the iterator pointing to the first element.

Definition at line 141 of file UnorderedMap.h.

◆ begin() [2/2]

template<typename TKey , typename TValue >
INLINE Iterator<const Element> UnorderedMap< TKey, TValue >::begin ( ) const
inline

Returns the iterator pointing to the first element.

Definition at line 146 of file UnorderedMap.h.

◆ clear()

template<typename TKey , typename TValue >
INLINE void UnorderedMap< TKey, TValue >::clear ( )
inline

Removes all elements from the map.

Definition at line 97 of file UnorderedMap.h.

◆ clone()

template<typename TKey , typename TValue >
UnorderedMap UnorderedMap< TKey, TValue >::clone ( ) const
inline

Definition at line 168 of file UnorderedMap.h.

◆ contains()

template<typename TKey , typename TValue >
INLINE bool UnorderedMap< TKey, TValue >::contains ( const TKey &  key) const
inline

Returns true if the map contains element of given key.

Equivalent to bool(tryGet(key)).

Definition at line 126 of file UnorderedMap.h.

◆ empty()

template<typename TKey , typename TValue >
INLINE Size UnorderedMap< TKey, TValue >::empty ( ) const
inline

Returns true if the map contains no elements, false otherwise.

Definition at line 136 of file UnorderedMap.h.

◆ end() [1/2]

template<typename TKey , typename TValue >
INLINE Iterator<Element> UnorderedMap< TKey, TValue >::end ( )
inline

Returns the iterator pointing to the one-past-last element.

Definition at line 151 of file UnorderedMap.h.

◆ end() [2/2]

template<typename TKey , typename TValue >
INLINE Iterator<const Element> UnorderedMap< TKey, TValue >::end ( ) const
inline

Returns the iterator pointing to the one-past-last element.

Definition at line 156 of file UnorderedMap.h.

◆ insert() [1/2]

template<typename TKey , typename TValue >
INLINE TValue& UnorderedMap< TKey, TValue >::insert ( const TKey &  key,
const TValue &  value 
)
inline

Adds a new element into the map or sets new value of element with the same key.

Definition at line 51 of file UnorderedMap.h.

◆ insert() [2/2]

template<typename TKey , typename TValue >
INLINE TValue& UnorderedMap< TKey, TValue >::insert ( const TKey &  key,
TValue &&  value 
)
inline

Adds a new element into the map or sets new value of element with the same key.

Definition at line 62 of file UnorderedMap.h.

◆ operator ArrayView< const Element >()

template<typename TKey , typename TValue >
INLINE UnorderedMap< TKey, TValue >::operator ArrayView< const Element > ( ) const
inline

Definition at line 164 of file UnorderedMap.h.

◆ operator ArrayView< Element >()

template<typename TKey , typename TValue >
INLINE UnorderedMap< TKey, TValue >::operator ArrayView< Element > ( )
inline

Definition at line 160 of file UnorderedMap.h.

◆ operator[]() [1/2]

template<typename TKey , typename TValue >
INLINE TValue& UnorderedMap< TKey, TValue >::operator[] ( const TKey &  key)
inline

Returns a reference to the element, given its key.

The element must exists in the map, checked by assert.

Definition at line 35 of file UnorderedMap.h.

◆ operator[]() [2/2]

template<typename TKey , typename TValue >
INLINE const TValue& UnorderedMap< TKey, TValue >::operator[] ( const TKey &  key) const
inline

Returns a reference to the element, given its key.

The element must exists in the map, checked by assert.

Definition at line 44 of file UnorderedMap.h.

◆ remove()

template<typename TKey , typename TValue >
INLINE void UnorderedMap< TKey, TValue >::remove ( const TKey &  key)
inline

Removes element with given key from the map.

The element must exists in the map, checked by assert.

Definition at line 75 of file UnorderedMap.h.

◆ size()

template<typename TKey , typename TValue >
INLINE Size UnorderedMap< TKey, TValue >::size ( ) const
inline

Returns the number of elements in the map.

Definition at line 131 of file UnorderedMap.h.

◆ tryGet() [1/2]

template<typename TKey , typename TValue >
INLINE Optional<TValue&> UnorderedMap< TKey, TValue >::tryGet ( const TKey &  key)
inline

Returns a reference to the value matching the given key, or NOTHING if no such value exists.

Safe alternative to operator[].

Definition at line 104 of file UnorderedMap.h.

◆ tryGet() [2/2]

template<typename TKey , typename TValue >
INLINE Optional<const TValue&> UnorderedMap< TKey, TValue >::tryGet ( const TKey &  key) const
inline

Returns a reference to the value matching the given key, or NOTHING if no such value exists.

Definition at line 114 of file UnorderedMap.h.

◆ tryRemove()

template<typename TKey , typename TValue >
INLINE bool UnorderedMap< TKey, TValue >::tryRemove ( const TKey &  key)
inline

Removes element with given key if present, otherwise it does nothing.

Returns
True if the element was removed, false otherwise.

Definition at line 85 of file UnorderedMap.h.


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