Simple map implemented on top of a std::list<std::pair>. The map is append-only, with lock-free reads and mutex-protected insert.
More...
|
const V & | at (const K &key) const |
| Get the stored value for the given key. More...
|
|
bool | contains (const K &key) const |
| Check whether the given key is stored in this map. More...
|
|
bool | empty () const |
| Return whether this map is empty. More...
|
|
template<typename... Args> |
V & | insertIfNew (const K &key, Args &&... args) |
| Search this map for the key. If it is not found, store the key with a value constructed from args. More...
|
|
V & | operator[] (const K &key) |
| Find (or insert a default-constructed value) the value for the given key. More...
|
|
size_t | size () const |
| Return the number of elements of this map. More...
|
|
template<typename K, typename V>
class cras::SmallMap< K, V >
Simple map implemented on top of a std::list<std::pair>. The map is append-only, with lock-free reads and mutex-protected insert.
This map is suitable for storing a small number of elements, as it uses non-sorted linear lookup of the values. However, if this condition is met, the map is reasonably fast and efficient.
- Template Parameters
-
K | Type of the map keys. |
V | Type of the map values (should support empty constructor). |
Definition at line 32 of file small_map.hpp.
template<typename K , typename V >
template<typename... Args>
V& cras::SmallMap< K, V >::insertIfNew |
( |
const K & |
key, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Search this map for the key. If it is not found, store the key with a value constructed from args.
- Parameters
-
key | The key to find. |
args | Arguments for the constructor of the inserted value. |
- Returns
- Reference to the value stored for the given key.
Definition at line 79 of file small_map.hpp.