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

Per-ID state kept between frames for the elements still built: an entry not written for kKeepFrames frames goes. More...

#include <gui_core/gui_recent_id_map.h>

Public Member Functions

V & operator[] (ID id)
 The value for id, made when absent; kept for kKeepFrames more frames.
void Touch (ID id)
 Keeps id's entry, when there is one, for kKeepFrames more frames.
V * Find (ID id)
 The value for id, or null. Reading doesn't keep it.
const V * Find (ID id) const
void Erase (ID id)
void Clear ()
size_t Size () const
template<typename Visit>
void ForEach (Visit &&visit)
 Calls visit(id, value) for each entry, in no particular order.
template<typename MayDrop>
void EndFrame (MayDrop &&mayDrop)
 Ends a frame.
void EndFrame ()

Static Public Attributes

static constexpr uint32_t kKeepFrames = 300
static constexpr uint32_t kSweepPeriod = 64
 frames between sweeps

Detailed Description

template<typename V>
class tachyon::RecentIDMap< V >

Per-ID state kept between frames for the elements still built: an entry not written for kKeepFrames frames goes.

For state an immediate-mode control keeps by its ID (last frame's rect, a measured width), which would otherwise grow by one entry for every ID ever shown.

m_widths[id] = width;               // written while the element is built: kept
if (const int* w = m_widths.Find(id)) ...
m_widths.EndFrame();                // once per frame 

Member Function Documentation

◆ operator[]()

template<typename V>
V & tachyon::RecentIDMap< V >::operator[] ( ID id)
inline

The value for id, made when absent; kept for kKeepFrames more frames.

◆ Touch()

template<typename V>
void tachyon::RecentIDMap< V >::Touch ( ID id)
inline

Keeps id's entry, when there is one, for kKeepFrames more frames.

◆ Find() [1/2]

template<typename V>
V * tachyon::RecentIDMap< V >::Find ( ID id)
inline

The value for id, or null. Reading doesn't keep it.

◆ Find() [2/2]

template<typename V>
const V * tachyon::RecentIDMap< V >::Find ( ID id) const
inline

◆ Erase()

template<typename V>
void tachyon::RecentIDMap< V >::Erase ( ID id)
inline

◆ Clear()

template<typename V>
void tachyon::RecentIDMap< V >::Clear ( )
inline

◆ Size()

template<typename V>
size_t tachyon::RecentIDMap< V >::Size ( ) const
inline

◆ ForEach()

template<typename V>
template<typename Visit>
void tachyon::RecentIDMap< V >::ForEach ( Visit && visit)
inline

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

◆ EndFrame() [1/2]

template<typename V>
template<typename MayDrop>
void tachyon::RecentIDMap< V >::EndFrame ( MayDrop && mayDrop)
inline

Ends a frame.

Every kSweepPeriod frames, drops the entries not written for kKeepFrames frames that mayDrop(id, value) agrees to (it can free what the value holds; return false to keep the entry anyway).

◆ EndFrame() [2/2]

template<typename V>
void tachyon::RecentIDMap< V >::EndFrame ( )
inline

Member Data Documentation

◆ kKeepFrames

template<typename V>
uint32_t tachyon::RecentIDMap< V >::kKeepFrames = 300
staticconstexpr

◆ kSweepPeriod

template<typename V>
uint32_t tachyon::RecentIDMap< V >::kSweepPeriod = 64
staticconstexpr

frames between sweeps


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