Template Class ConcurrentCuckooTable

Nested Relationships

Nested Types

Class Documentation

template<class K, class V, class H = DefaultHash<K>, class Eq = std::equal_to<K>>
class ConcurrentCuckooTable

a DICTIONARY shared by threads, cuckoo hashing with a lock per region

Public Types

using Key = K

the type of the keys

using Value = V

the type of the values

Public Functions

explicit ConcurrentCuckooTable(std::size_t n = 0, H h = H(), Eq eq = Eq())

the empty table, with room for n pairs before it grows

ConcurrentCuckooTable(const ConcurrentCuckooTable&) = delete
ConcurrentCuckooTable &operator=(const ConcurrentCuckooTable&) = delete
std::optional<V> find(const K &k) const

a copy of the value of the key k, or nothing

bool contains(const K &k) const
bool insert(const K &k, const V &v)

associates the value v to the key k if k is not there; true if it was not, and otherwise the value of k stays

bool insertOrAssign(const K &k, const V &v)

associates the value v to the key k; true if k was not there

template<class F>
bool update(const K &k, F &&f)

applies f( V & ) to the value of the key k under its locks; true if k is there

bool erase(const K &k)

removes the key k, if it is there; true if it was

std::size_t size(void) const

the pairs, exact when no operation runs

bool empty(void) const
std::size_t capacity(void) const

the places, 4 per bucket

std::size_t rehashes(void) const

the doublings of the table

void reserve(std::size_t n)

room for n pairs before the table grows

void clear(void)

removes every pair, keeping the capacity

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

applies f( const K & , V & ) to every pair, under all the locks

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

applies f( const K & , const V & ) to every pair, under all the locks

bool consistent(void) const

each key in one of its two buckets with its tag and once, and the counters summing to the pairs; under all the locks

Public Static Attributes

static constexpr bool optimistic = refLockFree<K>() && refLockFree<V>()

true if the lookups read without locks, under the versions of the stripes: the keys and the values trivially copyable, and read and written atomically without locks