jubilant-funicular
Public Member Functions | Private Attributes | List of all members
nta::utils::IDFactory< T > Class Template Reference

Class for generating unique (integral) IDs. More...

#include <IDFactory.h>

Collaboration diagram for nta::utils::IDFactory< T >:
Collaboration graph
[legend]

Public Member Functions

void clear ()
 Resets this to a new IDFactory.
 
void reset ()
 Resets this to a new IDFactory.
 
gen_id ()
 Generates a new, unused ID.
 
void free_id (T id)
 
void free (T id)
 calls free_id
 
bool is_free (T id) const
 Returns whether or not an id is free.
 
bool is_in_use (T id) const
 Returns whether or not the id is in use.
 
std::size_t get_count () const
 Returns the number of active ids.
 
get_last_id () const
 Returns m_last_id.
 
operator() ()
 Calls (and returns) gen_id.
 

Private Attributes

std::vector< T > m_free
 IDs that were previously active but have since been freed.
 
m_last_id
 The smallest id that has never been assigned.
 

Detailed Description

template<typename T>
class nta::utils::IDFactory< T >

Class for generating unique (integral) IDs.

Definition at line 14 of file IDFactory.h.

Member Function Documentation

◆ free_id()

template<typename T >
void nta::utils::IDFactory< T >::free_id ( id)

Marks an id as free so that it can be reused

id must not already be free

Definition at line 59 of file IDFactory.h.

Referenced by nta::utils::IDFactory< SlotMapKey<> >::free(), and nta::utils::IDFactory< GenIndex< IndexType, GenType > >::free().


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