![]() |
nCine 2022.04.r504-20bd01e
A cross-platform 2D game engine
|
A template based sparse set implementation. More...
#include <SparseSet.h>
Public Types | |
using | Iterator = SparseSetIterator< T > |
Iterator type. | |
using | ConstIterator = SparseSetIterator< T > |
Constant iterator type. | |
using | ReverseIterator = nctl::ReverseIterator< Iterator > |
Reverse iterator type. | |
using | ConstReverseIterator = nctl::ReverseIterator< ConstIterator > |
Reverse constant iterator type. | |
Public Member Functions | |
SparseSet (unsigned int capacity, unsigned int maxValue) | |
SparseSet (const SparseSet &other) | |
Copy constructor. | |
SparseSet (SparseSet &&other) | |
Move constructor. | |
SparseSet & | operator= (const SparseSet &other) |
Assignment operator. | |
SparseSet & | operator= (SparseSet &&other) |
Move assignment operator. | |
void | swap (SparseSet &first, SparseSet &second) |
Swaps two SparseSets without copying their data. | |
ConstIterator | begin () |
Returns a constant iterator to the first element. | |
ConstReverseIterator | rBegin () |
Returns a reverse constant iterator to the last element. | |
ConstIterator | end () |
Returns a constant iterator to past the last element. | |
ConstReverseIterator | rEnd () |
Returns a reverse constant iterator to prior the first element. | |
ConstIterator | begin () const |
Returns a constant iterator to the first element. | |
ConstReverseIterator | rBegin () const |
Returns a constant reverse iterator to the last element. | |
ConstIterator | end () const |
Returns a constant iterator to past the last lement. | |
ConstReverseIterator | rEnd () const |
Returns a constant reverse iterator to prior the first element. | |
ConstIterator | cBegin () const |
Returns a constant iterator to the first element. | |
ConstReverseIterator | crBegin () const |
Returns a constant reverse iterator to the last element. | |
ConstIterator | cEnd () const |
Returns a constant iterator to past the last lement. | |
ConstReverseIterator | crEnd () const |
Returns a constant reverse iterator to prior the first element. | |
bool | insert (T value) |
Inserts an element if not already in. | |
unsigned int | maxValue () const |
Returns the maximum value of the sparseset. | |
unsigned int | capacity () const |
Returns the capacity of the sparseset. | |
bool | isEmpty () const |
Returns true if the sparseset is empty. | |
unsigned int | size () const |
Returns the number of elements in the sparseset. | |
float | loadFactor () const |
Returns the ratio between used and total buckets. | |
void | clear () |
Clears the sparseset. | |
bool | contains (T value) const |
Checks whether an element is in the sparseset or not. | |
T | find (T value) const |
Checks whether an element is in the sparseset or not. | |
bool | remove (T value) |
Removes a key from the sparseset, if it exists. | |
void | rehash (unsigned int count) |
Sets the number of buckets to the new specified size and rehashes the container. | |
Static Public Attributes | |
static const T | NotFound = T(-1) |
Friends | |
class | SparseSetIterator< T > |
A template based sparse set implementation.
using nctl::SparseSet< T >::Iterator = SparseSetIterator<T> |
Iterator type.
Elements in the SparseSet can never be changed
bool nctl::SparseSet< T >::insert | ( | T | value | ) |
Inserts an element if not already in.
bool nctl::SparseSet< T >::remove | ( | T | value | ) |
Removes a key from the sparseset, if it exists.