nCine 2022.04.r504-20bd01e
A cross-platform 2D game engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
nctl::SparseSet< T > Class Template Reference

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.
 
SparseSetoperator= (const SparseSet &other)
 Assignment operator.
 
SparseSetoperator= (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.
 
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 constNotFound = T(-1)
 

Friends

class SparseSetIterator< T >
 

Detailed Description

template<class T>
class nctl::SparseSet< T >

A template based sparse set implementation.

Member Typedef Documentation

◆ Iterator

template<class T >
using nctl::SparseSet< T >::Iterator = SparseSetIterator<T>

Iterator type.

Elements in the SparseSet can never be changed

Member Function Documentation

◆ insert()

template<class T >
bool nctl::SparseSet< T >::insert ( value)

Inserts an element if not already in.

Returns
True if the element has been inserted

◆ remove()

template<class T >
bool nctl::SparseSet< T >::remove ( value)

Removes a key from the sparseset, if it exists.

Returns
True if the element has been found and removed

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