fennec
Loading...
Searching...
No Matches
fennec::map< KeyT, ValueT, Hash, Alloc >

Data Structure defining a mapping of key \(KeyT\) to value \(ValueT\). More...

#include <map.h>

Detailed Description

template<typename KeyT, typename ValueT, typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
struct fennec::map< KeyT, ValueT, Hash, Alloc >
Property Value
stable
dynamic
homogenous
distinct
ordered
space \(O(N)\)
linear
access \(O(1)\)
find \(O(1)\)
insertion \(O(1)\)
deletion \(O(1)\)
Template Parameters
KeyTThe Key Type
ValueTThe Value Type
HashThe Hash to Use
AllocThe Allocator to Use

Public Types

using key_t = KeyT
 The key type.
 
using value_t = ValueT
 The value type.
 
using elem_t = pair< KeyT, ValueT >
 then node type
 
using alloc_t = typename allocator_traits< Alloc >::template rebind< elem_t >
 Rebinds the allocator type to nodes.
 
using hash_t = Hash
 The hash type.
 
using set_t = set< elem_t, key_hash, key_equals, alloc_t >
 The underlying set.
 
using iterator = set_t::iterator
 Iterator type.
 

Public Member Functions

Constructors & Destructor
constexpr map ()=default
 Default Constructor, initializes empty map.
 
constexpr ~map ()=default
 Destructor, Destructs all elements and releases the allocation.
 
Properties
constexpr size_t size () const
 
constexpr size_t empty () const
 
constexpr size_t capacity () const
 
Access
constexpr value_toperator[] (const KeyT &key)
 Key Access Operator.
 
constexpr const value_toperator[] (const KeyT &key) const
 Key Const Access Operator.
 
template<typename... ArgsT>
constexpr value_toperator[] (ArgsT &&...args)
 Argument Key Access Operator.
 
template<typename... ArgsT>
constexpr const value_toperator[] (ArgsT &&...args) const
 Argument Key Const Access Operator.
 
Modifiers
constexpr void insert (elem_t &&pair)
 Key-Value Insertion.
 
template<typename... ArgsT>
constexpr void emplace (const KeyT &key, ArgsT &&...args)
 Key-Value Insertion.
 
template<typename... ArgsT>
constexpr void emplace (ArgsT &&...args)
 Key-Value Insertion.
 
constexpr void erase (KeyT &&key)
 Erase a key.
 
constexpr void erase (const KeyT &key)
 Erase a key.
 
template<typename... ArgsT>
constexpr void erase (ArgsT &&...args)
 Argument Erase.
 
void clear ()
 Clears the map destructing all elements.
 
Iteration
constexpr iterator begin ()
 C++ Iterator Specification begin()
 
constexpr iterator end ()
 C++ Iterator Specification end()
 

Member Function Documentation

◆ size()

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
constexpr size_t fennec::map< KeyT, ValueT, Hash, Alloc >::size ( ) const
inlineconstexpr
Returns
The size of the set

◆ empty()

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
constexpr size_t fennec::map< KeyT, ValueT, Hash, Alloc >::empty ( ) const
inlineconstexpr
Returns
true when there are no elements in the set, false otherwise

◆ capacity()

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
constexpr size_t fennec::map< KeyT, ValueT, Hash, Alloc >::capacity ( ) const
inlineconstexpr
Returns
The capacity of the underlying allocation

◆ operator[]() [1/4]

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
constexpr value_t * fennec::map< KeyT, ValueT, Hash, Alloc >::operator[] ( const KeyT &  key)
inlineconstexpr
Parameters
keyKey value to access
Returns
A pointer to the value associated with key, nullptr if key is not present.

◆ operator[]() [2/4]

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
constexpr const value_t * fennec::map< KeyT, ValueT, Hash, Alloc >::operator[] ( const KeyT &  key) const
inlineconstexpr
Parameters
keyKey value to access
Returns
A const-qualified pointer to the value associated with key, nullptr if key is not present.

◆ operator[]() [3/4]

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
template<typename... ArgsT>
constexpr value_t * fennec::map< KeyT, ValueT, Hash, Alloc >::operator[] ( ArgsT &&...  args)
inlineconstexpr
Template Parameters
ArgTArgument Type
Parameters
argArgument to construct the key with
Returns
A pointer to the value associated with key, nullptr if key is not present.

◆ operator[]() [4/4]

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
template<typename... ArgsT>
constexpr const value_t * fennec::map< KeyT, ValueT, Hash, Alloc >::operator[] ( ArgsT &&...  args) const
inlineconstexpr
Template Parameters
ArgsTArgument Type
Parameters
argsArgument to construct the key with
Returns
A const-qualified pointer to the value associated with key, nullptr if key is not present.

◆ insert()

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
constexpr void fennec::map< KeyT, ValueT, Hash, Alloc >::insert ( elem_t &&  pair)
inlineconstexpr
Parameters
paira pair containing the key and its value

◆ emplace() [1/2]

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
template<typename... ArgsT>
constexpr void fennec::map< KeyT, ValueT, Hash, Alloc >::emplace ( const KeyT &  key,
ArgsT &&...  args 
)
inlineconstexpr
Parameters
argsArguments for constructing the key-value pair

◆ emplace() [2/2]

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
template<typename... ArgsT>
constexpr void fennec::map< KeyT, ValueT, Hash, Alloc >::emplace ( ArgsT &&...  args)
inlineconstexpr
Parameters
argsArguments for constructing the key-value pair

◆ erase() [1/3]

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
constexpr void fennec::map< KeyT, ValueT, Hash, Alloc >::erase ( KeyT &&  key)
inlineconstexpr
Parameters
keykey to erase

◆ erase() [2/3]

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
constexpr void fennec::map< KeyT, ValueT, Hash, Alloc >::erase ( const KeyT &  key)
inlineconstexpr
Parameters
keykey to erase

◆ erase() [3/3]

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
template<typename... ArgsT>
constexpr void fennec::map< KeyT, ValueT, Hash, Alloc >::erase ( ArgsT &&...  args)
inlineconstexpr
Template Parameters
ArgsTArgument Types
Parameters
argsArguments to construct a key to erase

◆ begin()

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
constexpr iterator fennec::map< KeyT, ValueT, Hash, Alloc >::begin ( )
inlineconstexpr
Returns
an iterator at the start of the map

◆ end()

template<typename KeyT , typename ValueT , typename Hash = hash<KeyT>, typename Alloc = allocator<pair<KeyT, ValueT>>>
constexpr iterator fennec::map< KeyT, ValueT, Hash, Alloc >::end ( )
inlineconstexpr
Returns
an iterator at the end of the map

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