ActiveLib
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
active::container::HashMap< Key, T > Class Template Reference

#include <HashMap.h>

Inheritance diagram for active::container::HashMap< Key, T >:
Inheritance graph
[legend]
Collaboration diagram for active::container::HashMap< Key, T >:
Collaboration graph
[legend]

Public Types

using base = std::unordered_map<Key, std::unique_ptr<T>>
 Base container type.
 
using raw_type = std::pair<const Key, T>
 Paired key/raw value type.
 
using mapped_type = typename base::mapped_type
 Stored type.
 
using value_type = typename base::value_type
 Paired key/value type.
 
using node_type = typename base::node_type
 Node handle type.
 
using size_type = typename base::size_type
 Container size (index) type.
 
using iterator = typename base::iterator
 Container iterator type.
 
using const_iterator = typename base::const_iterator
 Container const iterator type.
 

Public Member Functions

 HashMap ()
 
 HashMap (const HashMap &source)
 
 HashMap (HashMap &&source)
 
virtual ~HashMap ()=default
 
auto operator= (const HashMap &source)
 
auto operator= (HashMap &&source)
 
mapped_typeoperator[] (const Key &key)
 
auto find (const Key &key) const
 
auto insert (const raw_type &item)
 
auto insert (const value_type &item)
 
auto insert (value_type &&item)
 
auto insert (node_type &&node)
 
auto emplace (const Key &key, mapped_type &&item)
 
auto emplace (const Key &key, T &&item)
 
auto release (iterator &pos)
 
auto release (const_iterator pos)
 

Detailed Description

template<class Key, class T>
requires utility::Clonable<T>
class active::container::HashMap< Key, T >

A specialisation class for an unordered map of objects wrapped in unique_ptr paired with a key

This allows map to store objects with polymorphic behaviour and object copying (object type must conform to Clonable). Keep in mind that the normal behaviour of the map is to take ownership of any objects stored in it (unless release is used)

NB: There is no requirement for container items to be non-null. It is entirely up the implementor if this rule should be adopted or enforced

Constructor & Destructor Documentation

◆ HashMap() [1/3]

template<class Key , class T >
active::container::HashMap< Key, T >::HashMap ( )
inline

Constructor

◆ HashMap() [2/3]

template<class Key , class T >
active::container::HashMap< Key, T >::HashMap ( const HashMap< Key, T > & source)
inline

Copy constructor

Parameters
sourceThe object to copy

◆ HashMap() [3/3]

template<class Key , class T >
active::container::HashMap< Key, T >::HashMap ( HashMap< Key, T > && source)
inline

Move constructor

Parameters
sourceThe object to move

◆ ~HashMap()

template<class Key , class T >
virtual active::container::HashMap< Key, T >::~HashMap ( )
virtualdefault

Destructor

Member Function Documentation

◆ emplace() [1/2]

template<class Key , class T >
auto active::container::HashMap< Key, T >::emplace ( const Key & key,
mapped_type && item )
inline

Emplace a key/value pair into the map

Parameters
itemThe key/value pair to insert (already wrapped in unique_ptr)
Here is the caller graph for this function:

◆ emplace() [2/2]

template<class Key , class T >
auto active::container::HashMap< Key, T >::emplace ( const Key & key,
T && item )
inline

Emplace a key/value pair into the map

Parameters
itemThe item to push

◆ find()

template<class Key , class T >
auto active::container::HashMap< Key, T >::find ( const Key & key) const
inline

Find a value with a specified key

Returns
An iterator pointing to the key/value pair (end() on failure)

◆ insert() [1/4]

template<class Key , class T >
auto active::container::HashMap< Key, T >::insert ( const raw_type & item)
inline

Insert a key/raw value pair into the map

Parameters
itemThe item to push
Returns
A map iterator pointing to the matching/inserted item paired with a bool (true if a new item was inserted)
Here is the call graph for this function:

◆ insert() [2/4]

template<class Key , class T >
auto active::container::HashMap< Key, T >::insert ( const value_type & item)
inline

Insert a key/value pair into the map

Parameters
itemThe item to push
Returns
A map iterator pointing to the matching/inserted item paired with a bool (true if a new item was inserted)
Here is the call graph for this function:

◆ insert() [3/4]

template<class Key , class T >
auto active::container::HashMap< Key, T >::insert ( node_type && node)
inline

Insert a map node

Parameters
nodeThe node to insert
Returns
A map iterator pointing to the matching/inserted item paired with a bool (true if a new item was inserted)

◆ insert() [4/4]

template<class Key , class T >
auto active::container::HashMap< Key, T >::insert ( value_type && item)
inline

Insert a key/object pair into the map

Parameters
itemThe item to push
Returns
A map iterator pointing to the matching/inserted item paired with a bool (true if a new item was inserted)
Here is the call graph for this function:

◆ operator=() [1/2]

template<class Key , class T >
auto active::container::HashMap< Key, T >::operator= ( const HashMap< Key, T > & source)
inline

Assignment operator

Parameters
sourceThe object to copy
Returns
A reference to this

◆ operator=() [2/2]

template<class Key , class T >
auto active::container::HashMap< Key, T >::operator= ( HashMap< Key, T > && source)
inline

Assignment operator

Parameters
sourceThe object to move
Returns
A reference to this

◆ operator[]()

template<class Key , class T >
mapped_type & active::container::HashMap< Key, T >::operator[] ( const Key & key)
inline

Subscript operator

Parameters
keyThe subscript key
Returns
A reference to the value paired with the key

◆ release() [1/2]

template<class Key , class T >
auto active::container::HashMap< Key, T >::release ( const_iterator pos)
inline

Release the pointer held by the specified item and erase

Parameters
posAn iterator pointing to the item to be removed
Returns
The released pointer from the map item

◆ release() [2/2]

template<class Key , class T >
auto active::container::HashMap< Key, T >::release ( iterator & pos)
inline

Release the pointer held by the specified item and erase

Parameters
posAn iterator pointing to the item to be removed
Returns
An iterator at the next value
Here is the call graph for this function:
Here is the caller graph for this function:

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