ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::DenseHashMap< K, V, H, Eq, A, Policy > Class Template Reference

a hash map with its pairs in a dense vector and an index of positions, its changes told through Policy More...

#include <ADS/dictionary/DenseHashMap.h>

Public types

using Key = K
 the type of the keys
using Value = V
 the type of the values
using Inserted = mod::Inserted< K , K , V >
 an insertion of a key, the key its handle
using Erased = mod::Erased< K , K , V >
 an erasure of a key, told before the removal
using Assigned = mod::Assigned< K , V >
 a change of the value of a key
using modifications
 the events: a key inserted or erased with its value, its value changed, the map emptied or rebuilt
using Subject
 the subject
using value_type = std::pair< K , V >
 the type of the items, for the standard library
using size_type = std::size_t
 the type of the sizes
using difference_type = std::ptrdiff_t
 the type of the distances between two iterators
using reference = const std::pair< K , V > &
 a reference to an item
using const_reference = const std::pair< K , V > &
 a constant reference to an item
using const_iterator
 the iterator on the items, constant
using iterator = const_iterator
 the iterator on the items
using allocator_type = A
 the type of the allocator

Public member functions

template<class... O>
 DenseHashMap (std::size_t n=0, H h=H(), Eq eq=Eq(), const A &alloc=A(), O &... o)
 the empty map, with room for \( n \) pairs before it grows, its pairs and groups from alloc, the static observers o...
 DenseHashMap (const DenseHashMap &o)
 a copy of other, on the allocator that select_on_container_copy_construction() gives
 DenseHashMap (const DenseHashMap &o, const A &alloc)
 a copy of other, on alloc
 DenseHashMap (DenseHashMap &&o) noexcept
 the pairs of o, which is left empty, with no places
 DenseHashMap (DenseHashMap &&o, const A &alloc)
 the pairs of o, which is left empty, on alloc: moved one by one if the allocators are not equal
DenseHashMap & operator= (DenseHashMap o) noexcept
 the assignment, by copy and swap, when the allocators are all equal
DenseHashMap & operator= (const DenseHashMap &o)
 the copy assignment, with the allocator of o if it propagates
DenseHashMap & operator= (DenseHashMap &&o)
 the move assignment: the memory of o if its allocator propagates or is equal, else its pairs moved one by one
 ~DenseHashMap ()=default
 frees the pairs and the groups
std::optional< V > lookup (const K &k) const
 the value of the key \( k \), or nothing
const V * find (const K &k) const
 the value of the key \( k \), nil if it is not there
V * find (const K &k)
 the value of the key \( k \), to change in place, nil if it is not there
bool insert (const K &k, const V &v)
 associates the value \( v \) to the key \( k \); true if \( k \) was not there
bool insert (K &&k, V &&v)
 as insert( k , v ), moving the key and the value
template<class... Args>
std::pair< V *, bool > try_emplace (const K &k, Args &&... a)
 the value of the key \( k \), built from a if \( k \) was not there, and true in that case; a key already there keeps its value and a is not touched.
template<class... Args>
std::pair< V *, bool > try_emplace (K &&k, Args &&... a)
 as try_emplace( k , a ), moving the key
bool remove (const K &k)
 removes the key \( k \), if it is there, moving the last pair into its position; true if it was
bool contains (const K &k) const
 true if the key \( k \) is there
std::size_t size (void) const
 the number \( n \) of pairs
bool empty (void) const
 true if there are no pairs
std::size_t capacity (void) const
 the number of places of the index, 12 times 0 or a power of 2 at least 2
double load (void) const
 the load factor \( n / m \) of the index, 0 with no places
std::size_t deleted (void) const
 the places of the index emptied by remove() in groups that some inspection went past, which count as full until the index is rebuilt; \( O( 1 ) \) time, the count kept by the operations
void reserve (std::size_t n)
 room for \( n \) pairs before the map grows
void clear (void)
 removes all the pairs, keeping the places
template<class F>
void forEach (F &&f) const
 f( k , v ) on the pairs, in the order of the vector
const std::pair< K, V > * data (void) const
 the pairs, in the order of the vector
void swap (DenseHashMap &o) noexcept(detail::swapNoexcept< A >)
 exchanges the contents with other in \( O( 1 ) \), and the allocators if they propagate on a swap
Subject & subject (void)
 the subject, for ADS::batch() and ADS::quiet()
const Subject & subject (void) const
 the subject
template<class O>
requires ( Subject::dynamic )
int attach (O &o)
 attaches the observer \( o \) and gives its number
void detach (int id)
 detaches the observer number \( \mathit{id} \)
allocator_type get_allocator (void) const
 the allocator of the pairs and of the groups
const_iterator begin (void) const
 the iterator on the first item
const_iterator end (void) const
 the iterator past the last item
const_iterator cbegin (void) const
 the constant iterator on the first item
const_iterator cend (void) const
 the constant iterator past the last item

Detailed description

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
class ADS::DenseHashMap< K, V, H, Eq, A, Policy >

a hash map with its pairs in a dense vector and an index of positions, its changes told through Policy

Member typedef documentation

◆ allocator_type

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::allocator_type = A

the type of the allocator

◆ Assigned

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::Assigned = mod::Assigned< K , V >

a change of the value of a key

◆ const_iterator

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::const_iterator
Initial value:
typename detail::AllocVector< A , std::pair< K , V > >::const_iterator
typename detail::AllocVector< A, std::pair< K, V > >::const_iterator const_iterator
the iterator on the items, constant
Definition DenseHashMap.h:408

the iterator on the items, constant

◆ const_reference

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::const_reference = const std::pair< K , V > &

a constant reference to an item

◆ difference_type

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::difference_type = std::ptrdiff_t

the type of the distances between two iterators

◆ Erased

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::Erased = mod::Erased< K , K , V >

an erasure of a key, told before the removal

◆ Inserted

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::Inserted = mod::Inserted< K , K , V >

an insertion of a key, the key its handle

◆ iterator

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::iterator = const_iterator

the iterator on the items

◆ Key

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::Key = K

the type of the keys

◆ modifications

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::modifications
Initial value:
a list of types, the events of a structure [see Modification.h]
Definition Modification.h:482

the events: a key inserted or erased with its value, its value changed, the map emptied or rebuilt

◆ reference

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::reference = const std::pair< K , V > &

a reference to an item

◆ size_type

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::size_type = std::size_t

the type of the sizes

◆ Subject

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::Subject
Initial value:
typename Policy::template bind< modifications ,
DenseHashMap(std::size_t n=0, H h=H(), Eq eq=Eq(), const A &alloc=A(), O &... o)
the empty map, with room for pairs before it grows, its pairs and groups from alloc,...
mod::list< Inserted, Erased, Assigned, mod::Cleared, mod::Rebuilt > modifications
the events: a key inserted or erased with its value, its value changed, the map emptied or rebuilt
Definition DenseHashMap.h:188

the subject

◆ Value

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::Value = V

the type of the values

◆ value_type

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
using ADS::DenseHashMap< K, V, H, Eq, A, Policy >::value_type = std::pair< K , V >

the type of the items, for the standard library

Constructor and destructor documentation

◆ DenseHashMap() [1/5]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
template<class... O>
ADS::DenseHashMap< K, V, H, Eq, A, Policy >::DenseHashMap ( std::size_t n = 0,
H h = H(),
Eq eq = Eq(),
const A & alloc = A(),
O &... o )
explicit

the empty map, with room for \( n \) pairs before it grows, its pairs and groups from alloc, the static observers o...

◆ DenseHashMap() [2/5]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
ADS::DenseHashMap< K, V, H, Eq, A, Policy >::DenseHashMap ( const DenseHashMap< K, V, H, Eq, A, Policy > & o)

a copy of other, on the allocator that select_on_container_copy_construction() gives

◆ DenseHashMap() [3/5]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
ADS::DenseHashMap< K, V, H, Eq, A, Policy >::DenseHashMap ( const DenseHashMap< K, V, H, Eq, A, Policy > & o,
const A & alloc )

a copy of other, on alloc

◆ DenseHashMap() [4/5]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
ADS::DenseHashMap< K, V, H, Eq, A, Policy >::DenseHashMap ( DenseHashMap< K, V, H, Eq, A, Policy > && o)
noexcept

the pairs of o, which is left empty, with no places

◆ DenseHashMap() [5/5]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
ADS::DenseHashMap< K, V, H, Eq, A, Policy >::DenseHashMap ( DenseHashMap< K, V, H, Eq, A, Policy > && o,
const A & alloc )

the pairs of o, which is left empty, on alloc: moved one by one if the allocators are not equal

◆ ~DenseHashMap()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
ADS::DenseHashMap< K, V, H, Eq, A, Policy >::~DenseHashMap ( )
default

frees the pairs and the groups

Member function documentation

◆ attach()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
template<class O>
requires ( Subject::dynamic )
int ADS::DenseHashMap< K, V, H, Eq, A, Policy >::attach ( O & o)
inline

attaches the observer \( o \) and gives its number

Precondition
no batch is open

◆ begin()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
const_iterator ADS::DenseHashMap< K, V, H, Eq, A, Policy >::begin ( void ) const
inlinenodiscard

the iterator on the first item

◆ capacity()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
std::size_t ADS::DenseHashMap< K, V, H, Eq, A, Policy >::capacity ( void ) const
nodiscard

the number of places of the index, 12 times 0 or a power of 2 at least 2

◆ cbegin()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
const_iterator ADS::DenseHashMap< K, V, H, Eq, A, Policy >::cbegin ( void ) const
inlinenodiscard

the constant iterator on the first item

◆ cend()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
const_iterator ADS::DenseHashMap< K, V, H, Eq, A, Policy >::cend ( void ) const
inlinenodiscard

the constant iterator past the last item

◆ clear()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
void ADS::DenseHashMap< K, V, H, Eq, A, Policy >::clear ( void )

removes all the pairs, keeping the places

◆ contains()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
bool ADS::DenseHashMap< K, V, H, Eq, A, Policy >::contains ( const K & k) const
nodiscard

true if the key \( k \) is there

◆ data()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
const std::pair< K, V > * ADS::DenseHashMap< K, V, H, Eq, A, Policy >::data ( void ) const
nodiscard

the pairs, in the order of the vector

◆ deleted()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
std::size_t ADS::DenseHashMap< K, V, H, Eq, A, Policy >::deleted ( void ) const
nodiscard

the places of the index emptied by remove() in groups that some inspection went past, which count as full until the index is rebuilt; \( O( 1 ) \) time, the count kept by the operations

◆ detach()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
void ADS::DenseHashMap< K, V, H, Eq, A, Policy >::detach ( int id)
inline

detaches the observer number \( \mathit{id} \)

Precondition
it is attached, no batch is open

◆ empty()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
bool ADS::DenseHashMap< K, V, H, Eq, A, Policy >::empty ( void ) const
nodiscard

true if there are no pairs

◆ end()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
const_iterator ADS::DenseHashMap< K, V, H, Eq, A, Policy >::end ( void ) const
inlinenodiscard

the iterator past the last item

◆ find() [1/2]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
V * ADS::DenseHashMap< K, V, H, Eq, A, Policy >::find ( const K & k)
nodiscard

the value of the key \( k \), to change in place, nil if it is not there

◆ find() [2/2]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
const V * ADS::DenseHashMap< K, V, H, Eq, A, Policy >::find ( const K & k) const
nodiscard

the value of the key \( k \), nil if it is not there

◆ forEach()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
template<class F>
void ADS::DenseHashMap< K, V, H, Eq, A, Policy >::forEach ( F && f) const

f( k , v ) on the pairs, in the order of the vector

◆ get_allocator()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
allocator_type ADS::DenseHashMap< K, V, H, Eq, A, Policy >::get_allocator ( void ) const
inlinenodiscard

the allocator of the pairs and of the groups

◆ insert() [1/2]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
bool ADS::DenseHashMap< K, V, H, Eq, A, Policy >::insert ( const K & k,
const V & v )

associates the value \( v \) to the key \( k \); true if \( k \) was not there

In pseudocode (beyond the book), the inspection of lookup():

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{insert}( k , v ) \cr 2 & \quad \textbf{if}\ k \text{ is there }\ \textbf{then}\ \text{give it } \text{the value } v;\ \textbf{return false} \cr 3 & \quad \textbf{if}\ \text{the places full or counted reach } 7 m / 8\ \textbf{then}\ \text{rebuild the index} \cr 4 & \quad ( g , j ) \gets \text{the first empty place of the inspection,} \text{ with } \beta \text{ set in the overflow of the full groups} \text{ passed} \cr 5 & \quad \text{append } ( k , v ) \text{ to } A; \ \text{the control byte } \text{of } j \gets t;\ g.\mathit{at}[ j ] \gets |A| - 1 \cr 6 & \quad \textbf{return true} \end{array}} \]

Postcondition
\( k \) is in the map

◆ insert() [2/2]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
bool ADS::DenseHashMap< K, V, H, Eq, A, Policy >::insert ( K && k,
V && v )

as insert( k , v ), moving the key and the value

◆ load()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
double ADS::DenseHashMap< K, V, H, Eq, A, Policy >::load ( void ) const
nodiscard

the load factor \( n / m \) of the index, 0 with no places

◆ lookup()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
std::optional< V > ADS::DenseHashMap< K, V, H, Eq, A, Policy >::lookup ( const K & k) const
nodiscard

the value of the key \( k \), or nothing

In pseudocode (the groups of Kulukundis and the overflow of Lopez Munoz, beyond the book), \( x \) the mixed hash of \( k \), \( t \) its fingerprint, \( \beta \) its bit of overflow and \( A \) the vector of the pairs:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{lookup}( k ) \cr 2 & \quad g \gets \text{the top bits of } x;\ i \gets 0 \cr 3 & \quad \textbf{loop} \cr 4 & \qquad \textbf{foreach}\ \text{place } j \text{ of the group } g \text{ whose control byte is } t\ \textbf{do} \cr 5 & \qquad\quad \textbf{if}\ A[ g.\mathit{at}[ j ] ].\mathit{key} = k \ \textbf{then return}\ A[ g.\mathit{at}[ j ] ].\mathit{value} \cr 6 & \qquad \textbf{if}\ \text{the overflow of } g \text{ lacks } \beta \ \textbf{then return nil} \cr 7 & \qquad i \gets i + 1;\ g \gets ( g + i ) \bmod G\quad \triangleright\ \text{the triangular order} \end{array}} \]

◆ operator=() [1/3]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
DenseHashMap & ADS::DenseHashMap< K, V, H, Eq, A, Policy >::operator= ( const DenseHashMap< K, V, H, Eq, A, Policy > & o)
inline

the copy assignment, with the allocator of o if it propagates

◆ operator=() [2/3]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
DenseHashMap & ADS::DenseHashMap< K, V, H, Eq, A, Policy >::operator= ( DenseHashMap< K, V, H, Eq, A, Policy > && o)
inline

the move assignment: the memory of o if its allocator propagates or is equal, else its pairs moved one by one

◆ operator=() [3/3]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
DenseHashMap & ADS::DenseHashMap< K, V, H, Eq, A, Policy >::operator= ( DenseHashMap< K, V, H, Eq, A, Policy > o)
noexcept

the assignment, by copy and swap, when the allocators are all equal

◆ remove()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
bool ADS::DenseHashMap< K, V, H, Eq, A, Policy >::remove ( const K & k)

removes the key \( k \), if it is there, moving the last pair into its position; true if it was

In pseudocode (beyond the book), \( p \) the position of \( k \) in \( A \):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{remove}( k ) \cr 2 & \quad ( g , j ) \gets \text{the place of } k;\ \textbf{if} \ \text{none } \textbf{then return false} \cr 3 & \quad p \gets g.\mathit{at}[ j ];\ \text{empty the place } j \text{ of } g \cr 4 & \quad \textbf{if}\ p < |A| - 1\ \textbf{then} \cr 5 & \qquad \text{the place of } A[ |A| - 1 ] \text{, by the inspection of } \text{its key, takes } p \cr 6 & \qquad A[ p ] \gets A[ |A| - 1 ] \cr 7 & \quad \text{remove the last pair of } A;\ \textbf{return true} \end{array}} \]

Postcondition
\( k \) is not in the map

◆ reserve()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
void ADS::DenseHashMap< K, V, H, Eq, A, Policy >::reserve ( std::size_t n)

room for \( n \) pairs before the map grows

◆ size()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
std::size_t ADS::DenseHashMap< K, V, H, Eq, A, Policy >::size ( void ) const
nodiscard

the number \( n \) of pairs

◆ subject() [1/2]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
Subject & ADS::DenseHashMap< K, V, H, Eq, A, Policy >::subject ( void )
inlinenodiscard

the subject, for ADS::batch() and ADS::quiet()

◆ subject() [2/2]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
const Subject & ADS::DenseHashMap< K, V, H, Eq, A, Policy >::subject ( void ) const
inlinenodiscard

the subject

◆ swap()

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
void ADS::DenseHashMap< K, V, H, Eq, A, Policy >::swap ( DenseHashMap< K, V, H, Eq, A, Policy > & o)
noexcept

exchanges the contents with other in \( O( 1 ) \), and the allocators if they propagate on a swap

Precondition
the allocators are equal, if they do not propagate

◆ try_emplace() [1/2]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
template<class... Args>
std::pair< V *, bool > ADS::DenseHashMap< K, V, H, Eq, A, Policy >::try_emplace ( const K & k,
Args &&... a )

the value of the key \( k \), built from a if \( k \) was not there, and true in that case; a key already there keeps its value and a is not touched.

The search is the one of insert(), so that a value read and then changed costs one inspection; the pointer is valid until the next insertion of a new key or removal

Postcondition
\( k \) is in the map

◆ try_emplace() [2/2]

template<class K, class V, class H = DefaultHash< K >, class Eq = std::equal_to< K >, class A = std::allocator< std::pair< const K , V > >, class Policy = NoObservers>
template<class... Args>
std::pair< V *, bool > ADS::DenseHashMap< K, V, H, Eq, A, Policy >::try_emplace ( K && k,
Args &&... a )

as try_emplace( k , a ), moving the key


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