ModErn Text Analysis
META Enumerates Textual Applications
|
A simple wrapper around a std::unordered_map that uses an internal mutex for synchronization safety. More...
#include <locking_map.h>
Public Types | |
using | iterator = typename std::unordered_map< Key, Value >::iterator |
iterator type for locking_maps | |
using | const_iterator = typename std::unordered_map< Key, Value >::const_iterator |
const_iterator type for locking_maps | |
Public Member Functions | |
locking_map ()=default | |
Default constructable. | |
locking_map (locking_map &&) | |
locking_map may be move constructed. | |
locking_map & | operator= (locking_map rhs) |
Locking map may be assigned. More... | |
void | swap (locking_map &other) |
Swaps the current instance of locking_map with the paramter. More... | |
void | insert (const Key &key, const Value &value) |
Inserts a given (key, value) pair into the map. More... | |
template<class... Args> | |
void | emplace (Args &&...args) |
Inserts a (key, value) pair into the map, using in-place construction. More... | |
util::optional< Value > | find (const Key &key) const |
Finds a value in the map. More... | |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
Private Attributes | |
std::unordered_map< Key, Value > | map_ |
the underlying map used for storage | |
std::mutex | mutables_ |
the mutex that synchronizes accesses into the map | |
A simple wrapper around a std::unordered_map that uses an internal mutex for synchronization safety.
locking_map< Key, Value > & meta::caching::locking_map< Key, Value >::operator= | ( | locking_map< Key, Value > | rhs | ) |
Locking map may be assigned.
void meta::caching::locking_map< Key, Value >::swap | ( | locking_map< Key, Value > & | other | ) |
Swaps the current instance of locking_map with the paramter.
other | the map to swap with |
void meta::caching::locking_map< Key, Value >::insert | ( | const Key & | key, |
const Value & | value | ||
) |
Inserts a given (key, value) pair into the map.
key | |
value |
void meta::caching::locking_map< Key, Value >::emplace | ( | Args &&... | args | ) |
Inserts a (key, value) pair into the map, using in-place construction.
args | the parameters to be used for creating the (key, value) pair |
util::optional< Value > meta::caching::locking_map< Key, Value >::find | ( | const Key & | key | ) | const |
Finds a value in the map.
If it exists, the optional will be engaged, otherwise, it will be disengaged.
key | the key to find the corresponding value for |
auto meta::caching::locking_map< Key, Value >::begin | ( | ) |
auto meta::caching::locking_map< Key, Value >::end | ( | ) |
auto meta::caching::locking_map< Key, Value >::begin | ( | ) | const |
auto meta::caching::locking_map< Key, Value >::end | ( | ) | const |