#include <MRMapOrHashMap.h>
Public Types | |
using | Dense = Vector<V, K> |
using | Hash = HashMap<K, V> |
Public Member Functions | |
void | setMap (Dense &&m) |
void | setHashMap (Hash &&m) |
void | resizeReserve (size_t denseTotalSize, size_t hashAdditionalCapacity) |
void | pushBack (K key, V val) |
template<typename F > | |
void | forEach (F &&f) const |
executes given function for all pairs (key, value) with valid value for dense map | |
Dense * | getMap () |
const Dense * | getMap () const |
Hash * | getHashMap () |
const Hash * | getHashMap () const |
void | clear () |
Static Public Member Functions | |
static MapOrHashMap | createMap (size_t size=0) |
static MapOrHashMap | createHashMap (size_t capacity=0) |
Public Attributes | |
std::variant< Dense, Hash > | var |
stores a mapping from keys K to values V in one of two forms: 1) as dense map (vector) preferable when there are few missing keys in a range [0, endKey) 2) as hash map preferable when valid keys are a small subset of the range
using MR::MapOrHashMap< K, V >::Dense = Vector<V, K> |
using MR::MapOrHashMap< K, V >::Hash = HashMap<K, V> |
void MR::MapOrHashMap< K, V >::clear | ( | ) |
|
inlinestaticnodiscard |
|
inlinestaticnodiscard |
void MR::MapOrHashMap< K, V >::forEach | ( | F && | f | ) | const |
executes given function for all pairs (key, value) with valid value for dense map
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
void MR::MapOrHashMap< K, V >::pushBack | ( | K | key, |
V | val ) |
appends one element in the map, in case of dense map, key must be equal to vector.endId()
void MR::MapOrHashMap< K, V >::resizeReserve | ( | size_t | denseTotalSize, |
size_t | hashAdditionalCapacity ) |
if this stores dense map then resizes it to denseTotalSize; if this stores hash map then sets its capacity to size()+hashAdditionalCapacity
|
inline |
|
inline |
std::variant<Dense, Hash> MR::MapOrHashMap< K, V >::var |