Skip to content

raisim::FlatHashMap ​

class · #include <raisim/FlatHashMap.hpp>

cpp
template <class Key, class Value, class Hash>
class FlatHashMap

Open-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

ParameterDescription
Keyequality-comparable key.
Valuedefault-constructible mapped type; a new entry is value-initialized.
Hashfunctor returning a well-mixed size_t (its low bits pick the slot).

Nested classes ​

Public member functions ​

size ​

cpp
size_t size() const

Returns the number of entries.

find ​

cpp
const Value *find(const Key &key) const

Returns 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.

RaiSim — physics for robotics and AI.