Luanti 5.16.0-dev
Loading...
Searching...
No Matches
ModifySafeMap< K, V > Class Template Reference

#include <container.h>

Collaboration diagram for ModifySafeMap< K, V >:

Classes

struct  IterationHelper

Public Types

typedef K key_type
typedef V mapped_type

Public Member Functions

 ModifySafeMap ()
 ~ModifySafeMap ()
const V & get (const K &key) const
void put (const K &key, const V &value)
void put (const K &key, V &&value)
take (const K &key)
bool remove (const K &key)
size_t size () const
bool empty () const
auto iter ()
void clear ()

Static Public Attributes

static const V null_value = V()
static constexpr size_t unknown = static_cast<size_t>(-1)

Protected Member Functions

void merge_new ()
void collect_garbage ()

Private Attributes

std::map< K, V > m_values
std::map< K, V > m_new
unsigned int m_iterating = 0
size_t m_garbage = 0

Static Private Attributes

static constexpr size_t GC_MIN_SIZE = 30

Member Typedef Documentation

◆ key_type

template<typename K, typename V>
typedef K ModifySafeMap< K, V >::key_type

◆ mapped_type

template<typename K, typename V>
typedef V ModifySafeMap< K, V >::mapped_type

Constructor & Destructor Documentation

◆ ModifySafeMap()

template<typename K, typename V>
ModifySafeMap< K, V >::ModifySafeMap ( )
inline

Referenced by ModifySafeMap< K, V >::IterationHelper::IterationHelper().

Here is the caller graph for this function:

◆ ~ModifySafeMap()

template<typename K, typename V>
ModifySafeMap< K, V >::~ModifySafeMap ( )
inline

Member Function Documentation

◆ clear()

template<typename K, typename V>
void ModifySafeMap< K, V >::clear ( )
inline

Referenced by TestDataStructures::testMap1(), and TestDataStructures::testMap2().

Here is the caller graph for this function:

◆ collect_garbage()

template<typename K, typename V>
void ModifySafeMap< K, V >::collect_garbage ( )
inlineprotected

◆ empty()

template<typename K, typename V>
bool ModifySafeMap< K, V >::empty ( ) const
inline
Warning
not constant-time!

◆ get()

template<typename K, typename V>
const V & ModifySafeMap< K, V >::get ( const K & key) const
inline

Referenced by TestDataStructures::testMap4(), and TestDataStructures::testMap5().

Here is the caller graph for this function:

◆ iter()

template<typename K, typename V>
auto ModifySafeMap< K, V >::iter ( )
inline

Referenced by TestDataStructures::testMap1(), TestDataStructures::testMap3(), TestDataStructures::testMap4(), and TestDataStructures::testMap5().

Here is the caller graph for this function:

◆ merge_new()

template<typename K, typename V>
void ModifySafeMap< K, V >::merge_new ( )
inlineprotected

◆ put() [1/2]

template<typename K, typename V>
void ModifySafeMap< K, V >::put ( const K & key,
const V & value )
inline

Referenced by TestDataStructures::testMap1(), TestDataStructures::testMap2(), TestDataStructures::testMap3(), TestDataStructures::testMap4(), and TestDataStructures::testMap5().

Here is the caller graph for this function:

◆ put() [2/2]

template<typename K, typename V>
void ModifySafeMap< K, V >::put ( const K & key,
V && value )
inline

◆ remove()

template<typename K, typename V>
bool ModifySafeMap< K, V >::remove ( const K & key)
inline

Referenced by TestDataStructures::testMap3().

Here is the caller graph for this function:

◆ size()

template<typename K, typename V>
size_t ModifySafeMap< K, V >::size ( ) const
inline
Warning
not constant-time!

Referenced by TestDataStructures::testMap4().

Here is the caller graph for this function:

◆ take()

template<typename K, typename V>
V ModifySafeMap< K, V >::take ( const K & key)
inline

Referenced by ModifySafeMap< u16, void * >::remove(), TestDataStructures::testMap3(), and TestDataStructures::testMap4().

Here is the caller graph for this function:

Member Data Documentation

◆ GC_MIN_SIZE

template<typename K, typename V>
size_t ModifySafeMap< K, V >::GC_MIN_SIZE = 30
staticconstexprprivate

◆ m_garbage

template<typename K, typename V>
size_t ModifySafeMap< K, V >::m_garbage = 0
private

◆ m_iterating

template<typename K, typename V>
unsigned int ModifySafeMap< K, V >::m_iterating = 0
private

◆ m_new

template<typename K, typename V>
std::map<K, V> ModifySafeMap< K, V >::m_new
private

◆ m_values

template<typename K, typename V>
std::map<K, V> ModifySafeMap< K, V >::m_values
private

◆ null_value

template<typename K, typename V>
const V ModifySafeMap< K, V >::null_value = V()
inlinestatic

◆ unknown

template<typename K, typename V>
size_t ModifySafeMap< K, V >::unknown = static_cast<size_t>(-1)
staticconstexpr

The documentation for this class was generated from the following file: