Provides an indexed free list with constant-time removals from anywhere in the list without invalidating indices. T must be trivially constructible and destructible.
More...
#include <FreeList.hpp>
|
| FreeList () |
| Creates a new free list. More...
|
|
int | insert (T element) |
| Inserts an element to the free list and returns an index to it. More...
|
|
void | remove (int n) |
| Removes the nth element from the free list. More...
|
|
void | clear () |
| Removes all elements from the free list and free the memory. More...
|
|
size_t | size () const |
| The number of active elements in the list. More...
|
|
void | reset () |
| Removes all elements from the list but doesn't free the memory. More...
|
|
std::vector< T > | toVector () const |
| Create a vector with all the values of the list. More...
|
|
int | range () const |
| Returns the range of valid indices. More...
|
|
int | findIndex (T element) const |
| Gives the index of an element, if not found returns -1. More...
|
|
T & | operator[] (int n) |
| Returns the nth element. More...
|
|
const T & | operator[] (int n) const |
| Returns the nth element. More...
|
|
void | forEach (std::function< bool(T &, int)> pred) |
| call pred with all the active elements More...
|
|
void | forEach (std::function< bool(T &)> pred) |
| call pred with all the active elements More...
|
|
void | forEach (std::function< bool(const T &, int)> pred) const |
| call pred with all the active elements More...
|
|
void | forEach (std::function< bool(const T &)> pred) const |
| call pred with all the active elements More...
|
|
|
static constexpr int | EndOfList = -1 |
| When this value is encountered in traversing a singly list it means it's the end of the list. More...
|
|
template<class T>
class Babel::FreeList< T >
Provides an indexed free list with constant-time removals from anywhere in the list without invalidating indices. T must be trivially constructible and destructible.
◆ FreeList()
◆ clear()
Removes all elements from the free list and free the memory.
◆ findIndex()
Gives the index of an element, if not found returns -1.
◆ forEach() [1/4]
template<class T >
void Babel::FreeList< T >::forEach |
( |
std::function< bool(const T &)> |
pred | ) |
const |
call pred with all the active elements
- Note
- pred argument element const ref
-
if the pred return false the forEach stop iterating and returns
◆ forEach() [2/4]
template<class T >
void Babel::FreeList< T >::forEach |
( |
std::function< bool(const T &, int)> |
pred | ) |
const |
call pred with all the active elements
- Note
- pred arguments 1: element ref, 2: index of the element
-
if the pred return false the forEach stop iterating and returns
◆ forEach() [3/4]
call pred with all the active elements
- Note
- pred argument element const ref
-
if the pred return false the forEach stop iterating and returns
◆ forEach() [4/4]
call pred with all the active elements
- Note
- pred arguments 1: element ref, 2: index of the element
-
if the pred return false the forEach stop iterating and returns
◆ insert()
Inserts an element to the free list and returns an index to it.
◆ operator[]() [1/2]
◆ operator[]() [2/2]
◆ range()
Returns the range of valid indices.
◆ remove()
Removes the nth element from the free list.
◆ reset()
Removes all elements from the list but doesn't free the memory.
- Note
- Function used to clear and quickly refill the list
◆ size()
The number of active elements in the list.
◆ toVector()
Create a vector with all the values of the list.
◆ _data
◆ _firstFree
◆ EndOfList
When this value is encountered in traversing a singly list it means it's the end of the list.
The documentation for this class was generated from the following file: