userver: rcu::RcuMap< Key, Value, RcuMapTraits >::InsertReturnTypeImpl< ValuePtrType > Struct Template Reference
Loading...
Searching...
No Matches
rcu::RcuMap< Key, Value, RcuMapTraits >::InsertReturnTypeImpl< ValuePtrType > Struct Template Reference

Detailed Description

template<typename Key, typename Value, typename RcuMapTraits>
template<typename ValuePtrType>
struct rcu::RcuMap< Key, Value, RcuMapTraits >::InsertReturnTypeImpl< ValuePtrType >

Definition at line 240 of file rcu_map.hpp.

Public Types

using Hash
 
using KeyEqual
 
using MutexType
 
using ValuePtr
 
using Iterator
 
using ConstValuePtr
 
using ConstIterator
 
using RawMap
 
using Snapshot
 
using InsertReturnType
 

Public Member Functions

RcuMap< K, V, RcuMapTraits >::InsertReturnType Emplace (const K &key, Args &&... args)
 
RcuMap< K, V, RcuMapTraits >::InsertReturnType TryEmplace (const K &key, Args &&... args)
 
 RcuMap ()=default
 
 RcuMap (const RcuMap &)=delete
 
 RcuMap (RcuMap &&)=delete
 
RcuMapoperator= (const RcuMap &)=delete
 
RcuMapoperator= (RcuMap &&)=delete
 
size_t SizeApprox () const
 Returns an estimated size of the map at some point in time.
 
const ConstValuePtr operator[] (const K &) const
 Returns a readonly value pointer by its key if exists.
 
const ValuePtr operator[] (const K &)
 Returns a modifiable value pointer by key if exists or default-creates one.
 
InsertReturnType Insert (const K &key, ValuePtr value)
 Inserts a new element into the container if there is no element with the key in the container. Returns a pair consisting of a pointer to the inserted element, or the already-existing element if no insertion happened, and a bool denoting whether the insertion took place.
 
InsertReturnType Emplace (const K &key, Args &&... args)
 Inserts a new element into the container constructed in-place with the given args if there is no element with the key in the container. Returns a pair consisting of a pointer to the inserted element, or the already-existing element if no insertion happened, and a bool denoting whether the insertion took place.
 
RcuMap< K, V, RcuMapTraits >::InsertReturnType Emplace (const K &key, Args &&... args)
 
InsertReturnType TryEmplace (const K &key, Args &&... args)
 If a key equivalent to key already exists in the container, does nothing. Otherwise, behaves like Emplace except that the element is constructed as std::make_shared<Value>(std::piecewise_construct, / std::forward_as_tuple(key), / std::forward_as_tuple(std::forward<Args>(args)...)). Returns a pair consisting of a pointer to the inserted element, or the already-existing element if no insertion happened, and a bool denoting whether the insertion took place.
 
RcuMap< K, V, RcuMapTraits >::InsertReturnType TryEmplace (const K &key, Args &&... args)
 
void InsertOrAssign (RawKey &&key, ValuePtr value)
 If a key equivalent to key already exists in the container, replaces the associated value. Otherwise, inserts a new pair into the map.
 
const ConstValuePtr Get (const K &) const
 Returns a readonly value pointer by its key or an empty pointer.
 
const ValuePtr Get (const K &)
 Returns a modifiable value pointer by key or an empty pointer.
 
bool Erase (const K &)
 Removes a key from the map.
 
ValuePtr Pop (const K &)
 Removes a key from the map returning its value.
 
void Clear ()
 Resets the map to an empty state.
 
void Assign (RawMap new_map)
 Replace current data by data from new_map.
 
rcu::WritablePtr< RawMap, RcuTraits > StartWrite ()
 Starts a transaction, used to perform a series of arbitrary changes to the map.
 
Snapshot GetSnapshot () const
 Returns a readonly copy of the map.
 
Iteration support

Keyset is fixed at the start of the iteration and is not affected by concurrent changes.

ConstIterator begin () const
 
Iterator begin ()
 
ConstIterator end () const
 
Iterator end ()
 

Public Attributes

ValuePtrType value
 
bool inserted
 

Member Typedef Documentation

◆ ConstIterator

using rcu::RcuMap< K, V, RcuMapTraits >::ConstIterator

Definition at line 132 of file rcu_map.hpp.

◆ ConstValuePtr

using rcu::RcuMap< K, V, RcuMapTraits >::ConstValuePtr

Definition at line 131 of file rcu_map.hpp.

◆ Hash

using rcu::RcuMap< K, V, RcuMapTraits >::Hash

Definition at line 126 of file rcu_map.hpp.

◆ InsertReturnType

using rcu::RcuMap< K, V, RcuMapTraits >::InsertReturnType

Definition at line 135 of file rcu_map.hpp.

◆ Iterator

using rcu::RcuMap< K, V, RcuMapTraits >::Iterator

Definition at line 130 of file rcu_map.hpp.

◆ KeyEqual

using rcu::RcuMap< K, V, RcuMapTraits >::KeyEqual

Definition at line 127 of file rcu_map.hpp.

◆ MutexType

using rcu::RcuMap< K, V, RcuMapTraits >::MutexType

Definition at line 128 of file rcu_map.hpp.

◆ RawMap

using rcu::RcuMap< K, V, RcuMapTraits >::RawMap

Definition at line 133 of file rcu_map.hpp.

◆ Snapshot

using rcu::RcuMap< K, V, RcuMapTraits >::Snapshot

Definition at line 134 of file rcu_map.hpp.

◆ ValuePtr

using rcu::RcuMap< K, V, RcuMapTraits >::ValuePtr

Definition at line 129 of file rcu_map.hpp.

Member Function Documentation

◆ Assign()

void rcu::RcuMap< K, V, RcuMapTraits >::Assign ( RawMap new_map)

Replace current data by data from new_map.

Definition at line 220 of file rcu_map.hpp.

◆ begin() [1/2]

RcuMap< K, V, RcuMapTraits >::Iterator rcu::RcuMap< K, V, RcuMapTraits >::begin ( )

Definition at line 153 of file rcu_map.hpp.

◆ begin() [2/2]

RcuMap< K, V, RcuMapTraits >::ConstIterator rcu::RcuMap< K, V, RcuMapTraits >::begin ( ) const

Definition at line 151 of file rcu_map.hpp.

◆ Clear()

void rcu::RcuMap< K, V, RcuMapTraits >::Clear ( )

Resets the map to an empty state.

Definition at line 217 of file rcu_map.hpp.

◆ Emplace() [1/3]

InsertReturnType rcu::RcuMap< K, V, RcuMapTraits >::Emplace ( const K & key,
Args &&... args )

Inserts a new element into the container constructed in-place with the given args if there is no element with the key in the container. Returns a pair consisting of a pointer to the inserted element, or the already-existing element if no insertion happened, and a bool denoting whether the insertion took place.

Note
Copies the whole map if the key doesn't exist.

◆ Emplace() [2/3]

RcuMap< K, V, RcuMapTraits >::InsertReturnType rcu::RcuMap< K, V, RcuMapTraits >::Emplace ( const K & key,
Args &&... args )

Definition at line 331 of file rcu_map.hpp.

◆ Emplace() [3/3]

RcuMap< K, V, RcuMapTraits >::InsertReturnType rcu::RcuMap< K, V, RcuMapTraits >::Emplace ( const K & key,
Args &&... args )

Definition at line 331 of file rcu_map.hpp.

◆ end() [1/2]

RcuMap< K, V, RcuMapTraits >::Iterator rcu::RcuMap< K, V, RcuMapTraits >::end ( )

Definition at line 154 of file rcu_map.hpp.

◆ end() [2/2]

RcuMap< K, V, RcuMapTraits >::ConstIterator rcu::RcuMap< K, V, RcuMapTraits >::end ( ) const

Definition at line 152 of file rcu_map.hpp.

◆ Erase()

bool rcu::RcuMap< K, V, RcuMapTraits >::Erase ( const K & )

Removes a key from the map.

Returns
whether the key was present
Note
Copies the whole map, might be slow for large maps.

Definition at line 209 of file rcu_map.hpp.

◆ GetSnapshot()

RcuMap< K, V, RcuMapTraits >::Snapshot rcu::RcuMap< K, V, RcuMapTraits >::GetSnapshot ( ) const

Returns a readonly copy of the map.

Note
Equivalent to {begin(), end()} construct, preferable for long-running operations.

Definition at line 230 of file rcu_map.hpp.

◆ Insert()

RcuMap< K, V, RcuMapTraits >::InsertReturnType rcu::RcuMap< K, V, RcuMapTraits >::Insert ( const K & key,
ValuePtr value )

Inserts a new element into the container if there is no element with the key in the container. Returns a pair consisting of a pointer to the inserted element, or the already-existing element if no insertion happened, and a bool denoting whether the insertion took place.

Note
Copies the whole map if the key doesn't exist.

Definition at line 172 of file rcu_map.hpp.

◆ InsertOrAssign()

void rcu::RcuMap< K, V, RcuMapTraits >::InsertOrAssign ( RawKey && key,
RcuMap::ValuePtr value )

If a key equivalent to key already exists in the container, replaces the associated value. Otherwise, inserts a new pair into the map.

Definition at line 198 of file rcu_map.hpp.

◆ operator[]() [1/2]

const ValuePtr rcu::RcuMap< K, V, RcuMapTraits >::operator[] ( const K & )

Returns a modifiable value pointer by key if exists or default-creates one.

Note
Copies the whole map if the key doesn't exist.

◆ operator[]() [2/2]

const ConstValuePtr rcu::RcuMap< K, V, RcuMapTraits >::operator[] ( const K & ) const

Returns a readonly value pointer by its key if exists.

Exceptions
MissingKeyExceptionif the key is not present

◆ Pop()

RcuMap< K, V, RcuMapTraits >::ValuePtr rcu::RcuMap< K, V, RcuMapTraits >::Pop ( const K & )

Removes a key from the map returning its value.

Returns
a value if the key was present, empty pointer otherwise
Note
Copies the whole map, might be slow for large maps.

Definition at line 214 of file rcu_map.hpp.

◆ SizeApprox()

size_t rcu::RcuMap< K, V, RcuMapTraits >::SizeApprox ( ) const

Returns an estimated size of the map at some point in time.

Definition at line 145 of file rcu_map.hpp.

◆ StartWrite()

auto rcu::RcuMap< K, V, RcuMapTraits >::StartWrite ( )

Starts a transaction, used to perform a series of arbitrary changes to the map.

The map is copied. Don't forget to Commit to apply the changes.

Definition at line 225 of file rcu_map.hpp.

◆ TryEmplace() [1/2]

RcuMap< K, V, RcuMapTraits >::InsertReturnType rcu::RcuMap< K, V, RcuMapTraits >::TryEmplace ( const K & key,
Args &&... args )

Definition at line 359 of file rcu_map.hpp.

◆ TryEmplace() [2/2]

RcuMap< K, V, RcuMapTraits >::InsertReturnType rcu::RcuMap< K, V, RcuMapTraits >::TryEmplace ( const K & key,
Args &&... args )

Definition at line 359 of file rcu_map.hpp.

Member Data Documentation

◆ inserted

template<typename Key, typename Value, typename RcuMapTraits>
template<typename ValuePtrType>
bool rcu::RcuMap< Key, Value, RcuMapTraits >::InsertReturnTypeImpl< ValuePtrType >::inserted

Definition at line 242 of file rcu_map.hpp.

◆ value

template<typename Key, typename Value, typename RcuMapTraits>
template<typename ValuePtrType>
ValuePtrType rcu::RcuMap< Key, Value, RcuMapTraits >::InsertReturnTypeImpl< ValuePtrType >::value

Definition at line 241 of file rcu_map.hpp.


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