![]() |
nCine 2022.04.r504-20bd01e
A cross-platform 2D game engine
|
A template based hashset implementation with open addressing and leapfrog probing. More...
#include <HashSet.h>
Public Types | |
using | Iterator = HashSetIterator< K, HashFunc > |
Iterator type. | |
using | ConstIterator = HashSetIterator< K, HashFunc > |
Constant iterator type. | |
using | ReverseIterator = nctl::ReverseIterator< Iterator > |
Reverse iterator type. | |
using | ConstReverseIterator = nctl::ReverseIterator< ConstIterator > |
Reverse constant iterator type. | |
Public Member Functions | |
HashSet (unsigned int capacity) | |
HashSet (const HashSet &other) | |
Copy constructor. | |
HashSet (HashSet &&other) | |
Move constructor. | |
HashSet & | operator= (const HashSet &other) |
Assignment operator. | |
HashSet & | operator= (HashSet &&other) |
Move assignment operator. | |
void | swap (HashSet &first, HashSet &second) |
Swaps two hashsets 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 (const K &key) |
Inserts an element if not already in. | |
bool | insert (K &&key) |
Moves an element if not already in. | |
unsigned int | capacity () const |
Returns the capacity of the hashset. | |
bool | isEmpty () const |
Returns true if the hashset is empty. | |
unsigned int | size () const |
Returns the number of elements in the hashset. | |
float | loadFactor () const |
Returns the ratio between used and total buckets. | |
hash_t | hash (const K &key) const |
Returns the hash of a given key. | |
void | clear () |
Clears the hashset. | |
bool | contains (const K &key) const |
Checks whether an element is in the hashset or not. | |
K * | find (const K &key) |
Checks whether an element is in the hashset or not. | |
const K * | find (const K &key) const |
Checks whether an element is in the hashset or not (read-only) | |
bool | remove (const K &key) |
Removes a key from the hashset, if it exists. | |
void | rehash (unsigned int count) |
Sets the number of buckets to the new specified size and rehashes the container. | |
Friends | |
class | HashSetIterator< K, HashFunc > |
struct | HashSetHelperTraits< K, HashFunc > |
A template based hashset implementation with open addressing and leapfrog probing.
using nctl::HashSet< K, HashFunc >::Iterator = HashSetIterator<K, HashFunc> |
Iterator type.
Elements in the hashset can never be changed
Checks whether an element is in the hashset or not.
K
is expensive, but always check the validity of returned pointer. const K * nctl::HashSet< K, HashFunc >::find | ( | const K & | key | ) | const |
Checks whether an element is in the hashset or not (read-only)
K
is expensive, but always check the validity of returned pointer. Inserts an element if not already in.
Moves an element if not already in.
Removes a key from the hashset, if it exists.