raisim::FlatHashMap
class · #include <raisim/FlatHashMap.hpp>
cpp
template <class Key, class Value, class Hash>
class FlatHashMapOpen-addressing hash map with linear probing in one contiguous slot array. The capacity is a power of two and the table grows at 50% load, so a lookup touches one or two cache lines and never divides. Pointers to values stay valid until the next insertion or eraseIf(). Iteration visits the occupied slots in table order.
Template parameters
| Parameter | Description |
|---|---|
Key | equality-comparable key. |
Value | default-constructible mapped type; a new entry is value-initialized. |
Hash | functor returning a well-mixed size_t (its low bits pick the slot). |
Nested classes
structSlot
Public member functions
size
cpp
size_t size() constReturns the number of entries.
find
cpp
const Value *find(const Key &key) constReturns the value of key, or nullptr when it is absent.
operator[]
cpp
Value &operator[](const Key &key)Returns the value of key, inserted value-initialized when it is absent.
eraseIf
cpp
template <class Pred>
void eraseIf(Pred erase)Removes every entry for which erase(key, value) is true. The table keeps its capacity.
forEach
cpp
template <class Visit>
void forEach(Visit visit)Calls visit(key, value) for every entry.