TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::IDMap< T > Class Template Reference

A hash map from ID to a small value, for indexes rebuilt or pruned every frame: open addressing in one array, so adding allocates nothing once the map has grown to the frame's size, and Clear keeps that room. More...

#include <gui_core/gui_id_map.h>

Public Member Functions

T * Find (ID key)
 The value held for key, or null.
const T * Find (ID key) const
std::pair< T *, bool > TryEmplace (ID key, const T &value)
 Adds key with value unless the key is there already.
void Clear ()
 Empties the map, keeping its room, unless that is far more than this fill needed: after one huge frame, later small ones don't pay to clear (or hold) all of it.
template<typename Visit>
void ForEach (Visit &&visit)
 Calls visit(key, value) for each entry, in no particular order.
template<typename Erase>
void EraseIf (Erase &&erase)
 Drops each entry erase(key, value) is true for.
size_t Size () const
size_t Capacity () const

Detailed Description

template<typename T>
class tachyon::IDMap< T >

A hash map from ID to a small value, for indexes rebuilt or pruned every frame: open addressing in one array, so adding allocates nothing once the map has grown to the frame's size, and Clear keeps that room.

Entries go only all at once (Clear) or by a sweep (EraseIf). ID::Invalid() marks a free slot, so it can't be a key.

Member Function Documentation

◆ Find() [1/2]

template<typename T>
T * tachyon::IDMap< T >::Find ( ID key)
inline

The value held for key, or null.

◆ Find() [2/2]

template<typename T>
const T * tachyon::IDMap< T >::Find ( ID key) const
inline

◆ TryEmplace()

template<typename T>
std::pair< T *, bool > tachyon::IDMap< T >::TryEmplace ( ID key,
const T & value )
inline

Adds key with value unless the key is there already.

Returns the value held for the key and whether it was added; {null, false} for ID::Invalid(), which marks a free slot and can't be a key.

◆ Clear()

template<typename T>
void tachyon::IDMap< T >::Clear ( )
inline

Empties the map, keeping its room, unless that is far more than this fill needed: after one huge frame, later small ones don't pay to clear (or hold) all of it.

◆ ForEach()

template<typename T>
template<typename Visit>
void tachyon::IDMap< T >::ForEach ( Visit && visit)
inline

Calls visit(key, value) for each entry, in no particular order.

◆ EraseIf()

template<typename T>
template<typename Erase>
void tachyon::IDMap< T >::EraseIf ( Erase && erase)
inline

Drops each entry erase(key, value) is true for.

Once over the table: the entries kept are set aside and added again, so the probe chains stay whole.

◆ Size()

template<typename T>
size_t tachyon::IDMap< T >::Size ( ) const
inline

◆ Capacity()

template<typename T>
size_t tachyon::IDMap< T >::Capacity ( ) const
inline

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