Luanti 5.10.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

◆ ~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

References ModifySafeMap< K, V >::m_garbage, ModifySafeMap< K, V >::m_iterating, and ModifySafeMap< K, V >::m_values.

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

References ModifySafeMap< K, V >::m_garbage, ModifySafeMap< K, V >::m_iterating, and ModifySafeMap< K, V >::m_values.

Referenced by ActiveObjectMgr< T >::~ActiveObjectMgr(), client::ActiveObjectMgr::~ActiveObjectMgr(), server::ActiveObjectMgr::~ActiveObjectMgr(), and ActiveObjectMgr< T >::clear().

+ Here is the caller graph for this function:

◆ get()

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

References ModifySafeMap< K, V >::m_iterating, ModifySafeMap< K, V >::m_new, ModifySafeMap< K, V >::m_values, and ModifySafeMap< K, V >::null_value.

Referenced by ActiveObjectMgr< T >::getActiveObject(), ActiveObjectMgr< T >::isFreeId(), TestDataStructures::testMap4(), and TestDataStructures::testMap5().

+ Here is the caller graph for this function:

◆ iter()

◆ 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

◆ 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

References ModifySafeMap< K, V >::take().

Referenced by ActiveObjectMgr< T >::clear(), server::ActiveObjectMgr::clearIf(), server::ActiveObjectMgr::removeObject(), and TestDataStructures::testMap3().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

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

References ModifySafeMap< K, V >::m_garbage, ModifySafeMap< K, V >::m_iterating, ModifySafeMap< K, V >::m_new, ModifySafeMap< K, V >::m_values, and ModifySafeMap< K, V >::unknown.

Referenced by server::ActiveObjectMgr::registerObject(), and 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

References ModifySafeMap< K, V >::m_garbage, ModifySafeMap< K, V >::m_iterating, ModifySafeMap< K, V >::m_new, and ModifySafeMap< K, V >::m_values.

Referenced by ModifySafeMap< K, V >::remove(), client::ActiveObjectMgr::removeObject(), 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

◆ m_iterating

◆ m_new

◆ m_values

◆ 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: