#include <Helpers.hh>
|
template<typename TKey , typename TValue > |
static TValue | lookup_map_entry (std::map< TKey, TValue > *&_map, std::mutex &_mutex, TKey _key, std::function< TValue(TKey)> create_value) |
|
template<typename TKey , typename TValue > |
static void | remove_map_entry (std::map< TKey, TValue > *&_map, std::mutex &_mutex, TKey _key) |
|
Definition at line 10 of file Helpers.hh.
◆ lookup_map_entry()
template<typename TKey , typename TValue >
static TValue lookup_map_entry |
( |
std::map< TKey, TValue > *& |
_map, |
|
|
std::mutex & |
_mutex, |
|
|
TKey |
_key, |
|
|
std::function< TValue(TKey)> |
create_value |
|
) |
| |
|
inlinestatic |
Definition at line 14 of file Helpers.hh.
15 {
16 std::lock_guard<std::mutex> lock (_mutex);
17 if (_map == nullptr) {
18 _map = new std::map<TKey,TValue> ();
19 }
20
21 TValue ret;
22 auto entry = _map->find (_key);
23 if (entry == _map->end ()) {
24 ret = create_value (_key);
25 } else {
26 ret = entry->second;
27 }
28
29 return ret;
30 }
◆ remove_map_entry()
template<typename TKey , typename TValue >
static void remove_map_entry |
( |
std::map< TKey, TValue > *& |
_map, |
|
|
std::mutex & |
_mutex, |
|
|
TKey |
_key |
|
) |
| |
|
inlinestatic |
Definition at line 33 of file Helpers.hh.
34 {
35 std::lock_guard<std::mutex> lock (_mutex);
36 if (_map == nullptr)
37 return;
38
39 auto entry = _map->find (_key);
40 if (entry == _map->end ())
41 return;
42
43 _map->erase (entry);
44 }
The documentation for this class was generated from the following file:
- /home/dank/src/dankamongmen/notcurses/include/ncpp/internal/Helpers.hh