Number5
Visualisierung 2 Project - Florian Schober (0828151, f.schober@live.com), Andreas Walch (0926780, walch.andreas89@gmail.com)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
IdCache< TId > Class Template Reference

#include <IdCache.hpp>

Public Member Functions

 IdCache ()
 
TId createId ()
 
void deleteId (TId id)
 
void reset ()
 

Private Attributes

vector< TId > m_unusedIds
 
TId m_highestId
 

Detailed Description

template<typename TId>
class IdCache< TId >

IdCache can be used to assign unique ids to objects. Ids that are "given back" (i.e. when the object is destructed) will be reused. 0 will never be assigned as id.

Definition at line 11 of file IdCache.hpp.

Constructor & Destructor Documentation

IdCache ( )
inline

Constructs an IdCache.

Definition at line 20 of file IdCache.hpp.

Member Function Documentation

TId createId ( )
inline

Creates a new id (or pops an unused one) and returns it.

Returns
The new id.

Definition at line 28 of file IdCache.hpp.

void deleteId ( TId  id)
inline

Gives back the passed id.

Returns
id The from now on unused id.

Definition at line 41 of file IdCache.hpp.

void reset ( )
inline

Resets its state to default. All used/unused ids will be forgotten.

Definition at line 50 of file IdCache.hpp.

Member Data Documentation

TId m_highestId
private

The next id that will be used (if there are no unused ids in the vector)

Definition at line 14 of file IdCache.hpp.

vector<TId> m_unusedIds
private

All ids that were given back and are not in use again

Definition at line 13 of file IdCache.hpp.


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