MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::MapOrHashMap< K, V > Struct Template Reference

#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
 
DensegetMap ()
 
const DensegetMap () const
 
HashgetHashMap ()
 
const HashgetHashMap () 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, Hashvar
 

Detailed Description

template<typename K, typename V>
struct MR::MapOrHashMap< K, V >

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

Member Typedef Documentation

◆ Dense

template<typename K , typename V >
using MR::MapOrHashMap< K, V >::Dense = Vector<V, K>

◆ Hash

template<typename K , typename V >
using MR::MapOrHashMap< K, V >::Hash = HashMap<K, V>

Member Function Documentation

◆ clear()

template<typename K , typename V >
void MR::MapOrHashMap< K, V >::clear ( )

◆ createHashMap()

template<typename K , typename V >
MapOrHashMap< K, V > MR::MapOrHashMap< K, V >::createHashMap ( size_t capacity = 0)
inlinestaticnodiscard

◆ createMap()

template<typename K , typename V >
MapOrHashMap< K, V > MR::MapOrHashMap< K, V >::createMap ( size_t size = 0)
inlinestaticnodiscard

◆ forEach()

template<typename K , typename V >
template<typename F >
void MR::MapOrHashMap< K, V >::forEach ( F && f) const

executes given function for all pairs (key, value) with valid value for dense map

◆ getHashMap() [1/2]

template<typename K , typename V >
Hash * MR::MapOrHashMap< K, V >::getHashMap ( )
inlinenodiscard

◆ getHashMap() [2/2]

template<typename K , typename V >
const Hash * MR::MapOrHashMap< K, V >::getHashMap ( ) const
inlinenodiscard

◆ getMap() [1/2]

template<typename K , typename V >
Dense * MR::MapOrHashMap< K, V >::getMap ( )
inlinenodiscard

◆ getMap() [2/2]

template<typename K , typename V >
const Dense * MR::MapOrHashMap< K, V >::getMap ( ) const
inlinenodiscard

◆ pushBack()

template<typename K , typename V >
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()

◆ resizeReserve()

template<typename K , typename V >
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

◆ setHashMap()

template<typename K , typename V >
void MR::MapOrHashMap< K, V >::setHashMap ( Hash && m)
inline

◆ setMap()

template<typename K , typename V >
void MR::MapOrHashMap< K, V >::setMap ( Dense && m)
inline

Member Data Documentation

◆ var

template<typename K , typename V >
std::variant<Dense, Hash> MR::MapOrHashMap< K, V >::var

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