#include <nCine/Base/StaticHashMap.h>
template<class K, class T, unsigned int Capacity, class HashFunc = FNV1aHashFunc<K>>
StaticHashMap class
Static hashmap implementation with open addressing and leapfrog probing (version with static allocation)
Public types
- using Iterator = StaticHashMapIterator<K, T, HashFunc, Capacity, false>
- Iterator type.
- using ConstIterator = StaticHashMapIterator<K, T, HashFunc, Capacity, true>
- Constant iterator type.
-
using ReverseIterator = nCine::
ReverseIterator<Iterator> - Reverse iterator type.
-
using ConstReverseIterator = nCine::
ReverseIterator<ConstIterator> - Reverse constant iterator type.
Constructors, destructors, conversion operators
- StaticHashMap()
- ~StaticHashMap()
- StaticHashMap(const StaticHashMap& other)
- Copy constructor.
- StaticHashMap(StaticHashMap&& other)
- Move constructor.
Public functions
- auto operator=(const StaticHashMap& other) -> StaticHashMap&
- Aassignment operator.
- auto operator=(StaticHashMap&& other) -> StaticHashMap&
- Move aassignment operator.
- auto begin() -> Iterator
- Returns an iterator to the first element.
- auto rbegin() -> ReverseIterator
- Returns a reverse iterator to the last element.
- auto end() -> Iterator
- Returns an iterator to past the last element.
- auto rend() -> ReverseIterator
- Returns a reverse iterator to prior the first element.
- auto begin() const -> ConstIterator
- Returns a constant iterator to the first element.
- auto rbegin() const -> ConstReverseIterator
- Returns a constant reverse iterator to the last element.
- auto end() const -> ConstIterator
- Returns a constant iterator to past the last lement.
- auto rend() const -> ConstReverseIterator
- Returns a constant reverse iterator to prior the first element.
- auto cbegin() const -> ConstIterator
- Returns a constant iterator to the first element.
- auto crbegin() const -> ConstReverseIterator
- Returns a constant reverse iterator to the last element.
- auto cend() const -> ConstIterator
- Returns a constant iterator to past the last lement.
- auto crend() const -> ConstReverseIterator
- Returns a constant reverse iterator to prior the first element.
- auto operator[](const K& key) -> T&
- Subscript operator.
- auto insert(const K& key, const T& value) -> bool
- Inserts an element if no other has the same key.
- auto insert(const K& key, T&& value) -> bool
- Moves an element if no other has the same key.
-
template<typename... Args>auto emplace(const K& key, Args && ... args) -> bool
- Constructs an element if no other has the same key.
- auto capacity() const -> unsigned int
- Returns the capacity of the hashmap.
- auto empty() const -> bool
- Returns true if the hashmap is empty.
- auto size() const -> unsigned int
- Returns the number of elements in the hashmap.
- auto loadFactor() const -> float
- Returns the ratio between used and total buckets.
-
auto hash(const K& key) const -> hash_
t - Returns the hash of a given key.
- void clear()
- Clears the hashmap.
- auto contains(const K& key, T& returnedValue) const -> bool
- Checks whether an element is in the hashmap or not.
- auto find(const K& key) -> T*
- Checks whether an element is in the hashmap or not.
- auto find(const K& key) const -> const T*
- Checks whether an element is in the hashmap or not (read-only)
- auto remove(const K& key) -> bool
- Removes a key from the hashmap, if it exists.
Function documentation
template<class K, class T, unsigned int Capacity, class HashFunc>
bool nCine:: StaticHashMap<K, T, Capacity, HashFunc>:: insert(const K& key,
const T& value)
Inserts an element if no other has the same key.
Returns | True if the element has been inserted |
---|
template<class K, class T, unsigned int Capacity, class HashFunc>
bool nCine:: StaticHashMap<K, T, Capacity, HashFunc>:: insert(const K& key,
T&& value)
Moves an element if no other has the same key.
Returns | True if the element has been inserted |
---|
template<class K, class T, unsigned int Capacity, class HashFunc>
template<typename... Args>
bool nCine:: StaticHashMap<K, T, Capacity, HashFunc>:: emplace(const K& key,
Args && ... args)
Constructs an element if no other has the same key.
Returns | True if the element has been emplaced |
---|
template<class K, class T, unsigned int Capacity, class HashFunc>
T* nCine:: StaticHashMap<K, T, Capacity, HashFunc>:: find(const K& key)
Checks whether an element is in the hashmap or not.
template<class K, class T, unsigned int Capacity, class HashFunc>
const T* nCine:: StaticHashMap<K, T, Capacity, HashFunc>:: find(const K& key) const
Checks whether an element is in the hashmap or not (read-only)
template<class K, class T, unsigned int Capacity, class HashFunc>
bool nCine:: StaticHashMap<K, T, Capacity, HashFunc>:: remove(const K& key)
Removes a key from the hashmap, if it exists.
Returns | True if the element has been found and removed |
---|