HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_CollapseIDs< S, T > Class Template Reference

#include <UT_CollapseIDs.h>

Public Member Functions

 UT_CollapseIDs ()
 
bool contains (const S &id) const
 Returns true if the id maps to something already. More...
 
T operator[] (const S &id)
 
void freeId (const S &id)
 

Protected Member Functions

SYS_FORCE_INLINE void returnValue (const T &value)
 
SYS_FORCE_INLINE T getFreeValue ()
 
SYS_FORCE_INLINE void decrementFreeStart ()
 

Protected Attributes

UT_Set< TmyFreeList
 
T myFreeStart
 All values equal to or greater than this value are free. More...
 
UT_Map< S, TmyMapping
 

Detailed Description

template<typename S, typename T>
class UT_CollapseIDs< S, T >

This class is designed to map integral values to integral values. For each newly-added mapping, the mapped value will be a unique integer that's guaranteed to be small.

Definition at line 28 of file UT_CollapseIDs.h.

Constructor & Destructor Documentation

template<typename S , typename T >
UT_CollapseIDs< S, T >::UT_CollapseIDs ( )
inline

Definition at line 31 of file UT_CollapseIDs.h.

Member Function Documentation

template<typename S , typename T >
bool UT_CollapseIDs< S, T >::contains ( const S id) const
inline

Returns true if the id maps to something already.

Definition at line 34 of file UT_CollapseIDs.h.

template<typename S , typename T >
SYS_FORCE_INLINE void UT_CollapseIDs< S, T >::decrementFreeStart ( )
inlineprotected

Decreases myFreeStart by 1 and also sweeps the free list to remove any entries that can be merged with it.

Definition at line 107 of file UT_CollapseIDs.h.

template<typename S , typename T >
void UT_CollapseIDs< S, T >::freeId ( const S id)
inline

This call removes the mapping from id, marking whatever it was mapped to as an available value.

Definition at line 58 of file UT_CollapseIDs.h.

template<typename S , typename T >
SYS_FORCE_INLINE T UT_CollapseIDs< S, T >::getFreeValue ( )
inlineprotected

Returns a free value, with some effort put into ensuring that the smallest free value is returned.

Definition at line 81 of file UT_CollapseIDs.h.

template<typename S , typename T >
T UT_CollapseIDs< S, T >::operator[] ( const S id)
inline

Returns the value that id maps to. If the mapping doesn't yet exist, a non-clashing one is registered.

Definition at line 41 of file UT_CollapseIDs.h.

template<typename S , typename T >
SYS_FORCE_INLINE void UT_CollapseIDs< S, T >::returnValue ( const T value)
inlineprotected

The given value is returned as free, making it available for subsequent requests for a free value.

Definition at line 70 of file UT_CollapseIDs.h.

Member Data Documentation

template<typename S , typename T >
UT_Set<T> UT_CollapseIDs< S, T >::myFreeList
protected

Set of free values; a value in this list is guaranteed to be free, and no value equal to or greater than myFreeStart-1 is in this set.

Definition at line 126 of file UT_CollapseIDs.h.

template<typename S , typename T >
T UT_CollapseIDs< S, T >::myFreeStart
protected

All values equal to or greater than this value are free.

Definition at line 128 of file UT_CollapseIDs.h.

template<typename S , typename T >
UT_Map<S, T> UT_CollapseIDs< S, T >::myMapping
protected

The actual mappings. This container ensures that no two myMapping[x] values will be the same.

Definition at line 131 of file UT_CollapseIDs.h.


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