ATLAS Offline Software
Loading...
Searching...
No Matches
CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL > Class Template Reference

Hash map from pointers/integers to arbitrary objects allowing concurrent, lockless reads. More...

#include <ConcurrentToValMap.h>

Collaboration diagram for CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >:

Classes

class  const_iterator
 Const iterator class. More...
struct  Hasher
class  iterator
 Iterator class. More...
struct  Matcher

Public Types

using key_type = KEY
 Standard STL types.
using mapped_type = VALUE
using size_type = size_t
using Updater_t = typename Impl_t::Updater_t
 Updater object.
using Context_t = typename Updater_t::Context_t
 Context type.
using const_iterator_value = std::pair<const key_type, const mapped_type&>
 Value structures for iterators.
using iterator_value = std::pair<const key_type, mapped_type&>
using const_iterator_range = CxxUtils::iterator_range<const_iterator>
 A range defined by two iterators.
using iterator_range = CxxUtils::iterator_range<iterator>

Public Member Functions

 ConcurrentToValMap (Updater_t &&updater, size_type capacity=64, const Context_t &ctx=Updater_t::defaultContext())
 Constructor.
 ConcurrentToValMap (const ConcurrentToValMap &other, Updater_t &&updater, size_t capacity=64, const Context_t &ctx=Updater_t::defaultContext())
 Constructor from another map.
template<class InputIterator>
 ConcurrentToValMap (InputIterator f, InputIterator l, Updater_t &&updater, size_type capacity=64, const Context_t &ctx=Updater_t::defaultContext())
 Constructor from a range.
 ConcurrentToValMap (const ConcurrentToValMap &other)=delete
 Copy / move / assign not supported.
 ConcurrentToValMap (ConcurrentToValMap &&other)=delete
ConcurrentToValMapoperator= (const ConcurrentToValMap &other)=delete
ConcurrentToValMapoperator= (ConcurrentToValMap &&other)=delete
 ~ConcurrentToValMap ()
 Destructor.
size_type size () const
 Return the number of items currently in the map.
bool empty () const
 Test if the map is currently empty.
size_t capacity () const
 Return the current size (capacity) of the hash table.
const_iterator_range range () const
 Return an iterator range covering the entire map.
iterator_range range ()
 Return an iterator range covering the entire map.
const_iterator begin () const
 Iterator at the start of the map.
const_iterator end () const
 Iterator at the end of the map.
iterator begin ()
 Iterator at the start of the map.
iterator end ()
 Iterator at the end of the map.
const_iterator cbegin () const
 Iterator at the start of the map.
const_iterator cend () const
 Iterator at the end of the map.
bool contains (const key_type key) const
 Test if a key is in the container.
size_type count (const key_type key) const
 Return the number of times a given key is in the container.
const_iterator find (const key_type key) const
 Look up an element in the map.
iterator find (const key_type key)
 Look up an element in the map.
const mapped_typeat (const key_type key) const
 Look up an element in the map.
mapped_typeat (const key_type key)
 Look up an element in the map.
std::pair< const_iterator, const_iteratorequal_range (const key_type key) const
 Return a range of iterators with entries matching key.
std::pair< iterator, iteratorequal_range (const key_type key)
 Return a range of iterators with entries matching key.
std::pair< const_iterator, bool > emplace (key_type key, const mapped_type &val, const Context_t &ctx=Updater_t::defaultContext())
 Add an element to the map.
std::pair< const_iterator, bool > emplace (key_type key, mapped_type &&val, const Context_t &ctx=Updater_t::defaultContext())
 Add an element to the map.
std::pair< const_iterator, bool > emplace (key_type key, std::unique_ptr< mapped_type > val, const Context_t &ctx=Updater_t::defaultContext())
 Add an element to the map.
template<class PAIR>
std::pair< const_iterator, bool > insert (const PAIR &p, const Context_t &ctx=Updater_t::defaultContext())
 Add an element to the map.
template<class PAIR>
std::pair< const_iterator, bool > insert (PAIR &&p, const Context_t &ctx=Updater_t::defaultContext())
 Add an element to the map.
template<class InputIterator>
void insert (InputIterator first, InputIterator last, const Context_t &ctx=Updater_t::defaultContext())
 Insert a range of elements to the map.
void reserve (size_type capacity, const Context_t &ctx=Updater_t::defaultContext())
 Increase the table capacity.
void rehash (size_type capacity)
 Increase the table capacity.
void quiescent (const Context_t &ctx)
 Called when this thread is no longer referencing anything from this container.
void swap (ConcurrentToValMap &other)
 Swap this container with another.
Updater_tupdater ()
 Access the Updater instance.

Private Types

using val_t = CxxUtils::detail::ConcurrentHashmapVal_t
 Representation type in the underlying map.
using Impl_t
 The underlying uint->uint hash table.

Private Member Functions

Impl_t::const_iterator get (const key_type key) const
 Do a lookup in the table.
std::pair< const_iterator, bool > put (const key_type key, std::unique_ptr< mapped_type > val, const Context_t &ctx=Updater_t::defaultContext())
 Insert an entry in the table.

Static Private Member Functions

static key_type keyAsKey (val_t val)
 Convert an underlying key value to this type's key value.
static val_t keyAsVal (key_type k)
 Convert this type's key value to an underlying key value.
static mapped_typemappedAsMapped (val_t val)
 Convert an underlying mapped value a pointer to this type's mapped value.
static val_t mappedAsVal (mapped_type *val)
 Convert this type's mapped value to an underlying mapped value.

Private Attributes

Impl_t m_impl
 The underlying hash table.

Detailed Description

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
requires (detail::IsConcurrentHashmapPayload<KEY> && detail::IsUpdater<UPDATER> && detail::IsHash<HASHER, KEY> && detail::IsBinaryPredicate<MATCHER, KEY>)
class CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >

Hash map from pointers/integers to arbitrary objects allowing concurrent, lockless reads.

This class implements a hash map, using keys that may be pointers or any integer type that can fit in an uintptr_t. The mapped type is arbitrary. It allows for concurrent access from many threads. Reads can proceed without taking out a lock, while writes are serialized with each other. Thus, this is appropriate for maps which are read-mostly.

This class includes non-const references that can be used to obtain non-const references to the mapped objects. Howeer, the mapped objects must themselves the thread-safe in order to safely modify them in a multithreaded context.

This is based on ConcurrentHashmapImpl.

Besides the key and mapped value types, this class is templated on an UPDATER class, which is used to manage the underlying memory. See IsUpdater.h for details. (AthenaKernel/RCUUpdater is a concrete version that should work in the context of Athena.)

The operations used for calculating the hash of the keys and comparing keys can be customized with the HASHER and MATCHER template arguments (though the defaults should usually be fine).

One value of the key must be reserved as a null value, which no real keys may take. By default this is ‘0’, but it may be customized with the NULLVAL template argument. Note that the type of the NULLPTR template argument is a uintptr_t, not KEY.

This mostly supports the interface of std::unordered_map, with a few differences / omissions:

  • Dereferencing the iterator returns a structure by value, not a reference.
  • No try_emplace.
  • No insert methods with hints.
  • No clear / erase / overwrite. Those could be implemented if needed (but would require some extra complexity in the memory management).
  • No operator==.
  • Nothing dealing with the bucket/node interface or merge().

The mapped value can be given as any of:

  • A value or const reference. In that case, it needs to be copy-constructable.
  • A rvalue-reference. In that case, it needs to be movable.
  • A unique_ptr to an instance.

I.e., any of these should work:

const Payload p (1);
map.emplace (1, p); // By value / const reference
map.emplace (2, Payload (2)); // By rvalue-reference.
// Could also move() an instance.
map.emplace (3, std::make_unique<Payload> (3)); // By unique_ptr.
Hash map from pointers/integers to arbitrary objects allowing concurrent, lockless reads.
STL class.

Definition at line 102 of file ConcurrentToValMap.h.

Member Typedef Documentation

◆ const_iterator_range

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::const_iterator_range = CxxUtils::iterator_range<const_iterator>

A range defined by two iterators.

Definition at line 399 of file ConcurrentToValMap.h.

◆ const_iterator_value

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::const_iterator_value = std::pair<const key_type, const mapped_type&>

Value structures for iterators.

For a map from K to V, a STL-style iterator should dereference to a std::pair<const K, V>. However, we don't actually store an object like that anywhere. In order to be able to have STL-like iterators, we instead use a pair where the second element is a const reference to the mapped value. We will return this by value when we deference an iterator. (The compiler should be able to optimize out the redundant packing and unpacking of fields.)

Definition at line 236 of file ConcurrentToValMap.h.

◆ Context_t

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::Context_t = typename Updater_t::Context_t

Context type.

Definition at line 141 of file ConcurrentToValMap.h.

◆ Impl_t

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::Impl_t
private
Initial value:

The underlying uint->uint hash table.

Definition at line 127 of file ConcurrentToValMap.h.

◆ iterator_range

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::iterator_range = CxxUtils::iterator_range<iterator>

Definition at line 400 of file ConcurrentToValMap.h.

◆ iterator_value

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::iterator_value = std::pair<const key_type, mapped_type&>

Definition at line 237 of file ConcurrentToValMap.h.

◆ key_type

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::key_type = KEY

Standard STL types.

Definition at line 135 of file ConcurrentToValMap.h.

◆ mapped_type

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::mapped_type = VALUE

Definition at line 136 of file ConcurrentToValMap.h.

◆ size_type

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::size_type = size_t

Definition at line 137 of file ConcurrentToValMap.h.

◆ Updater_t

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::Updater_t = typename Impl_t::Updater_t

Updater object.

Definition at line 139 of file ConcurrentToValMap.h.

◆ val_t

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
using CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::val_t = CxxUtils::detail::ConcurrentHashmapVal_t
private

Representation type in the underlying map.

Definition at line 106 of file ConcurrentToValMap.h.

Constructor & Destructor Documentation

◆ ConcurrentToValMap() [1/5]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::ConcurrentToValMap ( Updater_t && updater,
size_type capacity = 64,
const Context_t & ctx = Updater_t::defaultContext() )

Constructor.

Parameters
updaterObject used to manage memory (see comments at the start of the class).
capacityThe initial table capacity. (Will be rounded up to a power of two.)
ctxExecution context.

◆ ConcurrentToValMap() [2/5]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::ConcurrentToValMap ( const ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL > & other,
Updater_t && updater,
size_t capacity = 64,
const Context_t & ctx = Updater_t::defaultContext() )

Constructor from another map.

Parameters
updaterObject used to manage memory (see comments at the start of the class).
capacityThe initial table capacity of the new table. (Will be rounded up to a power of two.)
ctxExecution context.

(Not really a copy constructor since we need to pass updater.)

◆ ConcurrentToValMap() [3/5]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
template<class InputIterator>
CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::ConcurrentToValMap ( InputIterator f,
InputIterator l,
Updater_t && updater,
size_type capacity = 64,
const Context_t & ctx = Updater_t::defaultContext() )

Constructor from a range.

Parameters
fStart iterator for the range.
lEnd iterator for the range.
updaterObject used to manage memory (see comments at the start of the class).
capacityThe initial table capacity of the new table. (Will be rounded up to a power of two.)
ctxExecution context.

Constructor from a range of pairs.

◆ ConcurrentToValMap() [4/5]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::ConcurrentToValMap ( const ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL > & other)
delete

Copy / move / assign not supported.

◆ ConcurrentToValMap() [5/5]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::ConcurrentToValMap ( ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL > && other)
delete

◆ ~ConcurrentToValMap()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::~ConcurrentToValMap ( )

Destructor.

Member Function Documentation

◆ at() [1/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
mapped_type & CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::at ( const key_type key)

Look up an element in the map.

Parameters
keyThe element to find.

Returns the value associated with the key. Throws std::out_of_range if the key does not exist in the map.

This returns a non-const reference to the mapped object. The mapped object must be thread-safe itself in order to safely make any changes to it.

◆ at() [2/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
const mapped_type & CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::at ( const key_type key) const

Look up an element in the map.

Parameters
keyThe element to find.

Returns the value associated with the key. Throws std::out_of_range if the key does not exist in the map.

◆ begin() [1/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
iterator CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::begin ( )

Iterator at the start of the map.

The mapped objects must themselves be thread-safe in order to make any changes to them through the returned iterators.

◆ begin() [2/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
const_iterator CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::begin ( ) const

Iterator at the start of the map.

◆ capacity()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
size_t CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::capacity ( ) const

Return the current size (capacity) of the hash table.

◆ cbegin()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
const_iterator CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::cbegin ( ) const

Iterator at the start of the map.

◆ cend()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
const_iterator CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::cend ( ) const

Iterator at the end of the map.

◆ contains()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
bool CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::contains ( const key_type key) const

Test if a key is in the container.

Parameters
keyThe key to test.

◆ count()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
size_type CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::count ( const key_type key) const

Return the number of times a given key is in the container.

Parameters
keyThe key to test.

Returns either 0 or 1, depending on whether or not the key is in the map.

◆ emplace() [1/3]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
std::pair< const_iterator, bool > CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::emplace ( key_type key,
const mapped_type & val,
const Context_t & ctx = Updater_t::defaultContext() )

Add an element to the map.

Parameters
keyThe key of the new item to add.
valThe value of the new item to add.
ctxExecution context.

This will not overwrite an existing entry. The first element in the returned pair is an iterator referencing the added item. The second is a flag that is true if a new element was added.

◆ emplace() [2/3]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
std::pair< const_iterator, bool > CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::emplace ( key_type key,
mapped_type && val,
const Context_t & ctx = Updater_t::defaultContext() )

Add an element to the map.

Parameters
keyThe key of the new item to add.
valThe value of the new item to add.
ctxExecution context.

This will not overwrite an existing entry. The first element in the returned pair is an iterator referencing the added item. The second is a flag that is true if a new element was added.

◆ emplace() [3/3]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
std::pair< const_iterator, bool > CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::emplace ( key_type key,
std::unique_ptr< mapped_type > val,
const Context_t & ctx = Updater_t::defaultContext() )

Add an element to the map.

Parameters
keyThe key of the new item to add.
valThe value of the new item to add.
ctxExecution context.

This will not overwrite an existing entry. The first element in the returned pair is an iterator referencing the added item. The second is a flag that is true if a new element was added.

◆ empty()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
bool CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::empty ( ) const

Test if the map is currently empty.

◆ end() [1/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
iterator CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::end ( )

Iterator at the end of the map.

The mapped objects must themselves be thread-safe in order to make any changes to them through the returned iterators.

◆ end() [2/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
const_iterator CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::end ( ) const

Iterator at the end of the map.

◆ equal_range() [1/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
std::pair< iterator, iterator > CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::equal_range ( const key_type key)

Return a range of iterators with entries matching key.

Parameters
keyThe element to find.

As keys are unique in this container, this is either a single-element range, or both iterators are equal to end().

The mapped objects must themselves be thread-safe in order to make any changes to them through the returned iterators.

◆ equal_range() [2/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
std::pair< const_iterator, const_iterator > CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::equal_range ( const key_type key) const

Return a range of iterators with entries matching key.

Parameters
keyThe element to find.

As keys are unique in this container, this is either a single-element range, or both iterators are equal to end().

◆ find() [1/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
iterator CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::find ( const key_type key)

Look up an element in the map.

Parameters
keyThe element to find.

Returns either an iterator referencing the found element or end().

The mapped object must itself be thread-safe in order to make any changes to it through the returned iterator.

◆ find() [2/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
const_iterator CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::find ( const key_type key) const

Look up an element in the map.

Parameters
keyThe element to find.

Returns either an iterator referencing the found element or end().

◆ get()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
Impl_t::const_iterator CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::get ( const key_type key) const
private

Do a lookup in the table.

Parameters
keyThe key to look up.

Returns an iterator of the underlying map pointing at the found entry or end();

◆ insert() [1/3]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
template<class PAIR>
std::pair< const_iterator, bool > CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::insert ( const PAIR & p,
const Context_t & ctx = Updater_t::defaultContext() )

Add an element to the map.

Parameters
pThe item to add. Should be a pair where first is the string key and second is the integer value.
ctxExecution context.

This will not overwrite an existing entry. The first element in the returned pair is an iterator referencing the added item. The second is a flag that is true if a new element was added.

◆ insert() [2/3]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
template<class InputIterator>
void CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::insert ( InputIterator first,
InputIterator last,
const Context_t & ctx = Updater_t::defaultContext() )

Insert a range of elements to the map.

Parameters
firstStart of the range.
lastEnd of the range.
ctxExecution context.

The range should be a sequence of pairs where first is the string key and second is the integer value.

◆ insert() [3/3]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
template<class PAIR>
std::pair< const_iterator, bool > CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::insert ( PAIR && p,
const Context_t & ctx = Updater_t::defaultContext() )

Add an element to the map.

Parameters
pThe item to add. Should be a pair where first is the string key and second is the integer value.
ctxExecution context.

This will not overwrite an existing entry. The first element in the returned pair is an iterator referencing the added item. The second is a flag that is true if a new element was added.

◆ keyAsKey()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
key_type CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::keyAsKey ( val_t val)
staticprivate

Convert an underlying key value to this type's key value.

Parameters
valThe underlying key value.

◆ keyAsVal()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
val_t CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::keyAsVal ( key_type k)
staticprivate

Convert this type's key value to an underlying key value.

Parameters
kThe key.

◆ mappedAsMapped()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
mapped_type * CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::mappedAsMapped ( val_t val)
staticprivate

Convert an underlying mapped value a pointer to this type's mapped value.

Parameters
valThe underlying mapped value.

◆ mappedAsVal()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
val_t CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::mappedAsVal ( mapped_type * val)
staticprivate

Convert this type's mapped value to an underlying mapped value.

Parameters
valThe mapped value.

◆ operator=() [1/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
ConcurrentToValMap & CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::operator= ( ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL > && other)
delete

◆ operator=() [2/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
ConcurrentToValMap & CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::operator= ( const ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL > & other)
delete

◆ put()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
std::pair< const_iterator, bool > CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::put ( const key_type key,
std::unique_ptr< mapped_type > val,
const Context_t & ctx = Updater_t::defaultContext() )
private

Insert an entry in the table.

Parameters
keyThe key of the new item to add.
valThe new mapped value to add.
ctxExecution context.

The first element in the returned pair is an iterator referencing the added item. The second is a flag that is true if a new element was added.

◆ quiescent()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
void CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::quiescent ( const Context_t & ctx)

Called when this thread is no longer referencing anything from this container.

Parameters
ctxExecution context.

◆ range() [1/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
iterator_range CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::range ( )

Return an iterator range covering the entire map.

The mapped objects must themselves be thread-safe in order to make any changes to them through the returned iterators.

◆ range() [2/2]

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
const_iterator_range CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::range ( ) const

Return an iterator range covering the entire map.

◆ rehash()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
void CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::rehash ( size_type capacity)

Increase the table capacity.

Parameters
capacityThe new table capacity.

No action will be taken if capacity is smaller than the current capacity.

◆ reserve()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
void CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::reserve ( size_type capacity,
const Context_t & ctx = Updater_t::defaultContext() )

Increase the table capacity.

Parameters
capacityThe new table capacity.
ctxExecution context.

No action will be taken if capacity is smaller than the current capacity.

◆ size()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
size_type CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::size ( ) const

Return the number of items currently in the map.

◆ swap()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
void CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::swap ( ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL > & other)

Swap this container with another.

Parameters
otherThe container with which to swap.

This will also call swap on the Updater object; hence, the Updater object must also support swap.

This operation is NOT thread-safe. No other threads may be accessing either container during this operation.

◆ updater()

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
Updater_t & CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::updater ( )

Access the Updater instance.

Member Data Documentation

◆ m_impl

template<class KEY, class VALUE, template< class > class UPDATER, class HASHER = std::hash<KEY>, class MATCHER = std::equal_to<KEY>, detail::ConcurrentHashmapVal_t NULLVAL = 0>
Impl_t CxxUtils::ConcurrentToValMap< KEY, VALUE, UPDATER, HASHER, MATCHER, NULLVAL >::m_impl
private

The underlying hash table.

Definition at line 748 of file ConcurrentToValMap.h.


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