NebulaStream  0.6.213
NebulaStream is a data and application management framework for the internet of things
cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET > Class Template Reference

#include <cuckoohash_map.hh>

Classes

class  locked_table
 

Public Types

Type Declarations
using key_type = typename buckets_t::key_type
 
using mapped_type = typename buckets_t::mapped_type
 
using value_type = typename buckets_t::value_type
 
using size_type = typename buckets_t::size_type
 
using difference_type = std::ptrdiff_t
 
using hasher = Hash
 
using key_equal = KeyEqual
 
using allocator_type = typename buckets_t::allocator_type
 
using reference = typename buckets_t::reference
 
using const_reference = typename buckets_t::const_reference
 
using pointer = typename buckets_t::pointer
 
using const_pointer = typename buckets_t::const_pointer
 

Public Member Functions

Constructors, Destructors, and Assignment
 cuckoohash_map (size_type n=LIBCUCKOO_DEFAULT_SIZE, const Hash &hf=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
 
template<typename InputIt >
 cuckoohash_map (InputIt first, InputIt last, size_type n=LIBCUCKOO_DEFAULT_SIZE, const Hash &hf=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
 
 cuckoohash_map (const cuckoohash_map &other)
 
 cuckoohash_map (const cuckoohash_map &other, const Allocator &alloc)
 
 cuckoohash_map (cuckoohash_map &&other) noexcept
 
 cuckoohash_map (cuckoohash_map &&other, const Allocator &alloc)
 
 cuckoohash_map (std::initializer_list< value_type > init, size_type n=LIBCUCKOO_DEFAULT_SIZE, const Hash &hf=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
 
void swap (cuckoohash_map &other) noexcept
 
cuckoohash_mapoperator= (const cuckoohash_map &other)
 
cuckoohash_mapoperator= (cuckoohash_map &&other) noexcept
 
cuckoohash_mapoperator= (std::initializer_list< value_type > ilist)
 
Table Details

Methods for getting information about the table. Methods that query changing properties of the table are not synchronized with concurrent operations, and may return out-of-date information if the table is being concurrently modified. They will also continue to work after the container has been moved.

hasher hash_function () const
 
key_equal key_eq () const
 
allocator_type get_allocator () const
 
size_type hashpower () const
 
size_type bucket_count () const
 
bool empty () const
 
size_type size () const
 
size_type capacity () const
 
double load_factor () const
 
void minimum_load_factor (const double mlf)
 
double minimum_load_factor () const
 
void maximum_hashpower (size_type mhp)
 
size_type maximum_hashpower () const
 
void max_num_worker_threads (size_type extra_threads)
 
size_type max_num_worker_threads () const
 
Table Operations

These are operations that affect the data in the table. They are safe to call concurrently with each other.

template<typename K , typename F >
bool find_fn (const K &key, F fn) const
 
template<typename K , typename F >
bool update_fn (const K &key, F fn)
 
template<typename K , typename F >
bool erase_fn (const K &key, F fn)
 
template<typename K , typename F , typename... Args>
bool uprase_fn (K &&key, F fn, Args &&... val)
 
template<typename K , typename F , typename... Args>
bool upsert (K &&key, F fn, Args &&... val)
 
template<typename K >
bool find (const K &key, mapped_type &val) const
 
template<typename K >
mapped_type find (const K &key) const
 
template<typename K >
bool contains (const K &key) const
 
template<typename K , typename V >
bool update (const K &key, V &&val)
 
template<typename K , typename... Args>
bool insert (K &&key, Args &&... val)
 
template<typename K , typename V >
bool insert_or_assign (K &&key, V &&val)
 
template<typename K >
bool erase (const K &key)
 
bool rehash (size_type n)
 
bool reserve (size_type n)
 
void clear ()
 
locked_table lock_table ()
 

Static Public Member Functions

Table Parameters
static constexpr uint16_t slot_per_bucket ()
 

Friends

class UnitTestInternalAccess
 

Detailed Description

template<class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
class cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >

A concurrent hash table

Template Parameters
Keytype of keys in the table
Ttype of values in the table
Hashtype of hash functor
KeyEqualtype of equality comparison functor
Allocatortype of allocator. We suggest using an aligned allocator, because the table relies on types that are over-aligned to optimize concurrent cache usage.
SLOT_PER_BUCKETnumber of slots for each bucket in the table

Member Typedef Documentation

◆ allocator_type

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::allocator_type = typename buckets_t::allocator_type

◆ const_pointer

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::const_pointer = typename buckets_t::const_pointer

◆ const_reference

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::const_reference = typename buckets_t::const_reference

◆ difference_type

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::difference_type = std::ptrdiff_t

◆ hasher

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::hasher = Hash

◆ key_equal

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::key_equal = KeyEqual

◆ key_type

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::key_type = typename buckets_t::key_type

◆ mapped_type

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::mapped_type = typename buckets_t::mapped_type

◆ pointer

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::pointer = typename buckets_t::pointer

◆ reference

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::reference = typename buckets_t::reference

◆ size_type

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::size_type = typename buckets_t::size_type

◆ value_type

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
using cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::value_type = typename buckets_t::value_type

This type is defined as an std::pair. Note that table behavior is undefined if a user-defined specialization of std::pair<Key, T> or std::pair<const Key, T> exists.

Constructor & Destructor Documentation

◆ cuckoohash_map() [1/7]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::cuckoohash_map ( size_type  n = LIBCUCKOO_DEFAULT_SIZE,
const Hash &  hf = Hash(),
const KeyEqual &  equal = KeyEqual(),
const Allocator &  alloc = Allocator() 
)
inlineexplicit

Creates a new cuckohash_map instance

Parameters
nthe number of elements to reserve space for initially
hfhash function instance to use
equalequality function instance to use
allocallocator instance to use

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::bucket_count(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::get_allocator().

Here is the call graph for this function:

◆ cuckoohash_map() [2/7]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename InputIt >
cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::cuckoohash_map ( InputIt  first,
InputIt  last,
size_type  n = LIBCUCKOO_DEFAULT_SIZE,
const Hash &  hf = Hash(),
const KeyEqual &  equal = KeyEqual(),
const Allocator &  alloc = Allocator() 
)
inline

Constructs the map with the contents of the range [first, last]. If multiple elements in the range have equivalent keys, it is unspecified which element is inserted.

Parameters
firstthe beginning of the range to copy from
lastthe end of the range to copy from
nthe number of elements to reserve space for initially
hfhash function instance to use
equalequality function instance to use
allocallocator instance to use

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::insert().

Here is the call graph for this function:

◆ cuckoohash_map() [3/7]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::cuckoohash_map ( const cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET > &  other)
inline

Copy constructor. If other is being modified concurrently, behavior is unspecified.

Parameters
otherthe map being copied

◆ cuckoohash_map() [4/7]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::cuckoohash_map ( const cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET > &  other,
const Allocator &  alloc 
)
inline

Copy constructor with separate allocator. If other is being modified concurrently, behavior is unspecified.

Parameters
otherthe map being copied
allocthe allocator instance to use with the map

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::get_allocator().

Here is the call graph for this function:

◆ cuckoohash_map() [5/7]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::cuckoohash_map ( cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET > &&  other)
inlinenoexcept

Move constructor. If other is being modified concurrently, behavior is unspecified.

Parameters
otherthe map being moved

◆ cuckoohash_map() [6/7]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::cuckoohash_map ( cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET > &&  other,
const Allocator &  alloc 
)
inline

Move constructor with separate allocator. If the map being moved is being modified concurrently, behavior is unspecified.

Parameters
otherthe map being moved
allocthe allocator instance to use with the map

References backward::details::move().

Here is the call graph for this function:

◆ cuckoohash_map() [7/7]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::cuckoohash_map ( std::initializer_list< value_type init,
size_type  n = LIBCUCKOO_DEFAULT_SIZE,
const Hash &  hf = Hash(),
const KeyEqual &  equal = KeyEqual(),
const Allocator &  alloc = Allocator() 
)
inline

Constructs the map with the contents of initializer list init.

Parameters
initinitializer list to initialize the elements of the map with
nthe number of elements to reserve space for initially
hfhash function instance to use
equalequality function instance to use
allocallocator instance to use

Member Function Documentation

◆ bucket_count()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
size_type cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::bucket_count ( ) const
inline

Returns the number of buckets in the table.

Returns
the bucket count

References libcuckoo_bucket_container< Key, T, Allocator, Partial, SLOT_PER_BUCKET >::size().

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::capacity(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::cuckoohash_map().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ capacity()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
size_type cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::capacity ( ) const
inline

Returns the current capacity of the table, that is, bucket_count() × slot_per_bucket().

Returns
capacity of table

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::bucket_count(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::slot_per_bucket().

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::load_factor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
void cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::clear ( )
inline

Removes all elements in the table, calling their destructors.

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::operator=().

Here is the caller graph for this function:

◆ contains()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K >
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::contains ( const K &  key) const
inline

Returns whether or not key is in the table. Equivalent to find_fn with a functor that does nothing.

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::find_fn().

Here is the call graph for this function:

◆ empty()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::empty ( ) const
inline

Returns whether the table is empty or not.

Returns
true if the table is empty, false otherwise

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::size().

Here is the call graph for this function:

◆ erase()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K >
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::erase ( const K &  key)
inline

Erases the key from the table. Equivalent to calling erase_fn with a functor that just returns true.

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::erase_fn().

Here is the call graph for this function:

◆ erase_fn()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K , typename F >
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::erase_fn ( const K &  key,
fn 
)
inline

Searches for key in the table, and invokes fn on the value if the key is found. The functor can mutate the value, and should return true in order to erase the element, and false otherwise.

Template Parameters
Ktype of the key
Ftype of the functor. It should implement the method bool operator()(mapped_type&).
Parameters
keythe key to possibly erase from the table
fnthe functor to invoke if the element is found
Returns
true if key was found and fn invoked, false otherwise

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::erase().

Here is the caller graph for this function:

◆ find() [1/2]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K >
mapped_type cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::find ( const K &  key) const
inline

Searches the table for key, and returns the associated value it finds. mapped_type must be CopyConstructible.

Template Parameters
Ktype of the key
Parameters
keythe key to search for
Returns
the value associated with the given key
Exceptions
std::out_of_rangeif the key is not found

◆ find() [2/2]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K >
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::find ( const K &  key,
mapped_type val 
) const
inline

Copies the value associated with key into val. Equivalent to calling find_fn with a functor that copies the value into val. mapped_type must be CopyAssignable.

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::find_fn().

Here is the call graph for this function:

◆ find_fn()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K , typename F >
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::find_fn ( const K &  key,
fn 
) const
inline

Searches the table for key, and invokes fn on the value. fn is not allowed to modify the contents of the value if found.

Template Parameters
Ktype of the key. This can be any type comparable with key_type
Ftype of the functor. It should implement the method void operator()(const mapped_type&).
Parameters
keythe key to search for
fnthe functor to invoke if the element is found
Returns
true if the key was found and functor invoked, false otherwise

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::contains(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::find().

Here is the caller graph for this function:

◆ get_allocator()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
allocator_type cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::get_allocator ( ) const
inline

Returns the allocator associated with the map

Returns
the associated allocator

References libcuckoo_bucket_container< Key, T, Allocator, Partial, SLOT_PER_BUCKET >::get_allocator().

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::cuckoohash_map().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hash_function()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
hasher cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::hash_function ( ) const
inline

Returns the function that hashes the keys

Returns
the hash function

◆ hashpower()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
size_type cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::hashpower ( ) const
inline

Returns the hashpower of the table, which is log2(bucket_count()).

Returns
the hashpower

References libcuckoo_bucket_container< Key, T, Allocator, Partial, SLOT_PER_BUCKET >::hashpower().

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::maximum_hashpower().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K , typename... Args>
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::insert ( K &&  key,
Args &&...  val 
)
inline

Inserts the key-value pair into the table. Equivalent to calling upsert with a functor that does nothing.

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::upsert().

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::cuckoohash_map(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert_or_assign()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K , typename V >
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::insert_or_assign ( K &&  key,
V &&  val 
)
inline

Inserts the key-value pair into the table. If the key is already in the table, assigns the existing mapped value to val. Equivalent to calling upsert with a functor that assigns the mapped value to val.

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::upsert().

Here is the call graph for this function:

◆ key_eq()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
key_equal cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::key_eq ( ) const
inline

Returns the function that compares keys for equality

Returns
the key comparison function

◆ load_factor()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
double cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::load_factor ( ) const
inline

Returns the percentage the table is filled, that is, size() ÷ capacity().

Returns
load factor of the table

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::capacity(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::size().

Here is the call graph for this function:

◆ lock_table()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
locked_table cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::lock_table ( )
inline

Construct a locked_table object that owns all the locks in the table.

Returns
a locked_table instance

◆ max_num_worker_threads() [1/2]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
size_type cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::max_num_worker_threads ( ) const
inline

Returns the maximum number of extra worker threads.

◆ max_num_worker_threads() [2/2]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
void cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::max_num_worker_threads ( size_type  extra_threads)
inline

Set the maximum number of extra worker threads the table can spawn when doing large batch operations. Currently batch operations occur in the following scenarios.

  • Any resizing operation which invokes cuckoo_expand_simple. This includes any explicit rehash/resize operation, or any general resize if the data is not nothrow-move-constructible.
  • Creating a locked_table or resizing within a locked_table.
Parameters
num_threadsthe number of extra threads

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::operator=().

Here is the caller graph for this function:

◆ maximum_hashpower() [1/2]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
size_type cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::maximum_hashpower ( ) const
inline

Returns the maximum hashpower of the table

Returns
the maximum hashpower

◆ maximum_hashpower() [2/2]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
void cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::maximum_hashpower ( size_type  mhp)
inline

Sets the maximum hashpower the table can be. If set to LIBCUCKOO_NO_MAXIMUM_HASHPOWER, there will be no limit on the hashpower. Otherwise, the table will not be able to expand beyond the given hashpower, either by an explicit or an automatic expansion.

Parameters
mhpthe hashpower to set the maximum to
Exceptions
std::invalid_argumentif the current hashpower exceeds the limit

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::hashpower().

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ minimum_load_factor() [1/2]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
double cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::minimum_load_factor ( ) const
inline

Returns the minimum load factor of the table

Returns
the minimum load factor

◆ minimum_load_factor() [2/2]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
void cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::minimum_load_factor ( const double  mlf)
inline

Sets the minimum load factor allowed for automatic expansions. If an expansion is needed when the load factor of the table is lower than this threshold, libcuckoo_load_factor_too_low is thrown. It will not be thrown for an explicitly-triggered expansion.

Parameters
mlfthe load factor to set the minimum to
Exceptions
std::invalid_argumentif the given load factor is less than 0.0 or greater than 1.0

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::operator=().

Here is the caller graph for this function:

◆ operator=() [1/3]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
cuckoohash_map& cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::operator= ( const cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET > &  other)
inline

Copy assignment operator. If other is being modified concurrently, behavior is unspecified.

Parameters
otherthe map to assign from
Returns
*this

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::max_num_worker_threads(), cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::maximum_hashpower(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::minimum_load_factor().

Here is the call graph for this function:

◆ operator=() [2/3]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
cuckoohash_map& cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::operator= ( cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET > &&  other)
inlinenoexcept

Move assignment operator. If other is being modified concurrently, behavior is unspecified.

Parameters
otherthe map to assign from
Returns
*this

References backward::details::move().

Here is the call graph for this function:

◆ operator=() [3/3]

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
cuckoohash_map& cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::operator= ( std::initializer_list< value_type ilist)
inline

Initializer list assignment operator

Parameters
ilistan initializer list to assign from
Returns
*this

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::clear(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::insert().

Here is the call graph for this function:

◆ rehash()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::rehash ( size_type  n)
inline

Resizes the table to the given hashpower. If this hashpower is not larger than the current hashpower, then it decreases the hashpower to the maximum of the specified value and the smallest hashpower that can hold all the elements currently in the table.

Parameters
nthe hashpower to set for the table
Returns
true if the table changed size, false otherwise

References magic_enum::detail::n().

Here is the call graph for this function:

◆ reserve()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::reserve ( size_type  n)
inline

Reserve enough space in the table for the given number of elements. If the table can already hold that many elements, the function will shrink the table to the smallest hashpower that can hold the maximum of the specified amount and the current table size.

Parameters
nthe number of elements to reserve space for
Returns
true if the size of the table changed, false otherwise

References magic_enum::detail::n().

Here is the call graph for this function:

◆ size()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
size_type cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::size ( ) const
inline

Returns the number of elements in the table.

Returns
number of elements in the table

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::empty(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::load_factor().

Here is the caller graph for this function:

◆ slot_per_bucket()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
static constexpr uint16_t cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::slot_per_bucket ( )
inlinestaticconstexpr

The number of slots per hash bucket

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::capacity(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table::slot_per_bucket().

Here is the caller graph for this function:

◆ swap()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
void cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::swap ( cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET > &  other)
inlinenoexcept

Exchanges the contents of the map with those of other

Parameters
otherthe map to exchange contents with

References std::swap(), and libcuckoo_bucket_container< Key, T, Allocator, Partial, SLOT_PER_BUCKET >::swap().

Here is the call graph for this function:

◆ update()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K , typename V >
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::update ( const K &  key,
V &&  val 
)
inline

Updates the value associated with key to val. Equivalent to calling update_fn with a functor that assigns the existing mapped value to val. mapped_type must be MoveAssignable or CopyAssignable.

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::update_fn().

Here is the call graph for this function:

◆ update_fn()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K , typename F >
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::update_fn ( const K &  key,
fn 
)
inline

Searches the table for key, and invokes fn on the value. fn is allow to modify the contents of the value if found.

Template Parameters
Ktype of the key. This can be any type comparable with key_type
Ftype of the functor. It should implement the method void operator()(mapped_type&).
Parameters
keythe key to search for
fnthe functor to invoke if the element is found
Returns
true if the key was found and functor invoked, false otherwise

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::update().

Here is the caller graph for this function:

◆ uprase_fn()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K , typename F , typename... Args>
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::uprase_fn ( K &&  key,
fn,
Args &&...  val 
)
inline

Searches for key in the table. If the key is found, then fn is called on the existing value, and nothing happens to the passed-in key and values. The functor can mutate the value, and should return true in order to erase the element, and false otherwise. If the key is not found and must be inserted, the pair will be constructed by forwarding the given key and values. If there is no room left in the table, it will be automatically expanded. Expansion may throw exceptions.

Template Parameters
Ktype of the key
Ftype of the functor. It should implement the method bool operator()(mapped_type&).
Argslist of types for the value constructor arguments
Parameters
keythe key to insert into the table
fnthe functor to invoke if the element is found. If your fn needs more data that just the value being modified, consider implementing it as a lambda with captured arguments.
vala list of constructor arguments with which to create the value
Returns
true if a new key was inserted, false if the key was already in the table

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::upsert().

Here is the caller graph for this function:

◆ upsert()

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
template<typename K , typename F , typename... Args>
bool cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::upsert ( K &&  key,
fn,
Args &&...  val 
)
inline

Equivalent to calling uprase_fn with a functor that modifies the given value and always returns false (meaning the element is not removed). The passed-in functor must implement the method void operator()(mapped_type&).

References cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::uprase_fn().

Referenced by cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::insert(), and cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::insert_or_assign().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ UnitTestInternalAccess

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<const Key, T>>, std::size_t SLOT_PER_BUCKET = LIBCUCKOO_DEFAULT_SLOT_PER_BUCKET>
friend class UnitTestInternalAccess
friend

The documentation for this class was generated from the following file: