![]() |
nCine 2022.04.r504-20bd01e
A cross-platform 2D game engine
|
A template based hashset implementation with separate chaining and list head cell. More...
#include <HashSetList.h>
Public Types | |
using | Iterator = HashSetListIterator< K, HashFunc > |
Iterator type. | |
using | ConstIterator = HashSetListIterator< 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 | |
HashSetList (unsigned int capacity) | |
HashSetList (const HashSetList &other) | |
Copy constructor. | |
HashSetList (HashSetList &&other) | |
Move constructor. | |
HashSetList & | operator= (const HashSetList &other) |
Assignment operator. | |
HashSetList & | operator= (HashSetList &&other) |
Move assignment operator. | |
Iterator | begin () |
Returns an iterator to the first element. | |
ReverseIterator | rBegin () |
Returns a reverse iterator to the last element. | |
Iterator | end () |
Returns an iterator to past the last element. | |
ReverseIterator | rEnd () |
Returns a reverse 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 no other has the same key. | |
bool | insert (K &&key) |
Moves an element if no other has the same key. | |
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 average number of elements per bucket,. | |
unsigned int | bucketAmount () const |
Returns the number of buckets. | |
unsigned int | bucketSize (const K &key) const |
Returns the size of the bucket for the hash generated by the specified key. | |
unsigned int | bucket (const K &key) const |
Returns the index of the bucket for the hash generated by the specified key. | |
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 | HashSetListIterator< K, HashFunc > |
struct | HashSetListHelperTraits< K, HashFunc > |
A template based hashset implementation with separate chaining and list head cell.
Checks whether an element is in the hashSet or not.
T
is expensive, but always check the validity of returned pointer. const K * nctl::HashSetList< K, HashFunc >::find | ( | const K & | key | ) | const |
Checks whether an element is in the hashSet or not (read-only)
T
is expensive, but always check the validity of returned pointer. Inserts an element if no other has the same key.
Moves an element if no other has the same key.