![]() |
nCine 2022.04.r504-20bd01e
A cross-platform 2D game engine
|
A template based hashmap implementation with separate chaining and list head cell. More...
#include <HashMapList.h>
Public Types | |
using | Iterator = HashMapListIterator< K, T, HashFunc, false > |
Iterator type. | |
using | ConstIterator = HashMapListIterator< K, T, HashFunc, true > |
Constant iterator type. | |
using | ReverseIterator = nctl::ReverseIterator< Iterator > |
Reverse iterator type. | |
using | ConstReverseIterator = nctl::ReverseIterator< ConstIterator > |
Reverse constant iterator type. | |
Public Member Functions | |
HashMapList (unsigned int capacity) | |
HashMapList (const HashMapList &other) | |
Copy constructor. | |
HashMapList (HashMapList &&other) | |
Move constructor. | |
HashMapList & | operator= (const HashMapList &other) |
Assignment operator. | |
HashMapList & | operator= (HashMapList &&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. | |
T & | operator[] (const K &key) |
Subscript operator. | |
bool | insert (const K &key, const T &value) |
Inserts an element if no other has the same key. | |
bool | insert (const K &key, T &&value) |
Moves an element if no other has the same key. | |
template<typename... Args> | |
bool | emplace (const K &key, Args &&... args) |
Constructs an element if no other has the same key. | |
bool | isEmpty () const |
Returns true if the hashmap is empty. | |
unsigned int | size () const |
Returns the number of elements in the hashmap. | |
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 hashmap. | |
bool | contains (const K &key, T &returnedValue) const |
Checks whether an element is in the hashmap or not. | |
T * | find (const K &key) |
Checks whether an element is in the hashmap or not. | |
const T * | find (const K &key) const |
Checks whether an element is in the hashmap or not (read-only) | |
bool | remove (const K &key) |
Removes a key from the hashmap, if it exists. | |
void | rehash (unsigned int count) |
Sets the number of buckets to the new specified size and rehashes the container. | |
Friends | |
class | HashMapListIterator< K, T, HashFunc, false > |
class | HashMapListIterator< K, T, HashFunc, true > |
struct | HashMapListHelperTraits< K, T, HashFunc, false > |
struct | HashMapListHelperTraits< K, T, HashFunc, true > |
A template based hashmap implementation with separate chaining and list head cell.
bool nctl::HashMapList< K, T, HashFunc >::emplace | ( | const K & | key, |
Args &&... | args | ||
) |
Constructs an element if no other has the same key.
T * nctl::HashMapList< K, T, HashFunc >::find | ( | const K & | key | ) |
Checks whether an element is in the hashmap or not.
T
is expensive, but always check the validity of returned pointer. const T * nctl::HashMapList< K, T, HashFunc >::find | ( | const K & | key | ) | const |
Checks whether an element is in the hashmap or not (read-only)
T
is expensive, but always check the validity of returned pointer. bool nctl::HashMapList< K, T, HashFunc >::insert | ( | const K & | key, |
const T & | value | ||
) |
Inserts an element if no other has the same key.
bool nctl::HashMapList< K, T, HashFunc >::insert | ( | const K & | key, |
T && | value | ||
) |
Moves an element if no other has the same key.