Template Class PointerTable

Nested Relationships

Nested Types

Class Documentation

template<class T, class Eq = StateEqual, class A = std::allocator<std::byte>>
class PointerTable

a hash table of pointers to objects found by their keys

Public Types

using value_type = T*
using size_type = std::size_t
using difference_type = std::ptrdiff_t
using reference = T*
using const_reference = T*
using const_iterator = SlotIterator<PointerTable, Places>
using iterator = const_iterator

Public Functions

explicit PointerTable(std::size_t capacity = 16, Eq eq = Eq(), const A &alloc = A())

a table of at least capacity places, a power of 2, at least 16

PointerTable(const PointerTable&) = default
PointerTable &operator=(const PointerTable&) = default
PointerTable(PointerTable &&o) noexcept

the table of o, which is left empty, with no places until an insertion

PointerTable &operator=(PointerTable &&o) noexcept
void clear(void)

no object, the places kept; the objects are not touched

void reserve(std::size_t n)

room for n objects with no growth

template<class K, class Make>
std::pair<T*, bool> find_or_insert(const K &key, std::uint64_t hash, Make &&make)

the object of the key, whose hash is hash, and false; if there is none, the object that make() returns, now in the table, and true

Post:

the result is not nil

template<class K>
T *find(const K &key, std::uint64_t hash) const

the object of the key, nil if there is none

void prefetch(std::uint64_t hash) const

brings in the cache the first place of hash

std::size_t size(void) const

the number of objects

std::size_t capacity(void) const

the number of places

std::size_t bytes(void) const

the memory of the places, in bytes

template<class F>
void forEach(F &&f) const

f( p ) on each object, in the order of the places

inline const_iterator begin(void) const
inline const_iterator end(void) const
inline const_iterator cbegin(void) const
inline const_iterator cend(void) const
struct Places

the places of the table, for SlotIterator

Public Static Functions

static inline std::size_t size(const auto &o)
static inline bool occupied(const auto &o, std::size_t i)
static inline auto read(const auto &o, std::size_t i)