libcuckoo  0.3.1
Classes | Friends | List of all members
libcuckoo::cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table Class Reference

#include <cuckoohash_map.hh>

Classes

class  const_iterator
 
class  iterator
 

Public Types

Type Declarations
using key_type = typename cuckoohash_map::key_type
 
using mapped_type = typename cuckoohash_map::mapped_type
 
using value_type = typename cuckoohash_map::value_type
 
using size_type = typename cuckoohash_map::size_type
 
using difference_type = typename cuckoohash_map::difference_type
 
using hasher = typename cuckoohash_map::hasher
 
using key_equal = typename cuckoohash_map::key_equal
 
using allocator_type = typename cuckoohash_map::allocator_type
 
using reference = typename cuckoohash_map::reference
 
using const_reference = typename cuckoohash_map::const_reference
 
using pointer = typename cuckoohash_map::pointer
 
using const_pointer = typename cuckoohash_map::const_pointer
 

Public Member Functions

Constructors, Destructors, and Assignment
 locked_table ()=delete
 
 locked_table (const locked_table &)=delete
 
locked_tableoperator= (const locked_table &)=delete
 
 locked_table (locked_table &&lt) noexcept
 
locked_tableoperator= (locked_table &&lt) noexcept
 
void unlock ()
 
Table Details

Methods for getting information about the table. Many are identical to their cuckoohash_map counterparts. Only new functions or those with different behavior are documented.

bool is_active () const
 
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
 
Iterators
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
Modifiers
void clear ()
 
template<typename K , typename... Args>
std::pair< iterator, bool > insert (K &&key, Args &&... val)
 
iterator erase (const_iterator pos)
 
iterator erase (iterator pos)
 
template<typename K >
size_type erase (const K &key)
 
Lookup
template<typename K >
iterator find (const K &key)
 
template<typename K >
const_iterator find (const K &key) const
 
template<typename K >
mapped_type & at (const K &key)
 
template<typename K >
const mapped_type & at (const K &key) const
 
template<typename K >
T & operator[] (K &&key)
 
template<typename K >
size_type count (const K &key) const
 
template<typename K >
std::pair< iterator, iteratorequal_range (const K &key)
 
template<typename K >
std::pair< const_iterator, const_iteratorequal_range (const K &key) const
 
Re-sizing
void rehash (size_type n)
 
void reserve (size_type n)
 
Comparison


bool operator== (const locked_table &lt) const
 
bool operator!= (const locked_table &lt) const
 

Static Public Member Functions

Table Parameters
static constexpr size_type slot_per_bucket ()
 

Friends

class cuckoohash_map
 
std::ostream & operator<< (std::ostream &os, const locked_table &lt)
 
std::istream & operator>> (std::istream &is, locked_table &lt)
 

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 = DEFAULT_SLOT_PER_BUCKET>
class libcuckoo::cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table

An ownership wrapper around a cuckoohash_map table instance. When given a table instance, it takes all the locks on the table, blocking all outside operations on the table. Because the locked_table has unique ownership of the table, it can provide a set of operations on the table that aren't possible in a concurrent context.

The locked_table interface is very similar to the STL unordered_map interface, and for functions whose signatures correspond to unordered_map methods, the behavior should be mostly the same.

Member Function Documentation

◆ begin()

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 = DEFAULT_SLOT_PER_BUCKET>
iterator libcuckoo::cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table::begin ( )
inline

Returns an iterator to the beginning of the table. If the table is empty, it will point past the end of the table.

Returns
an iterator to the beginning of the table

◆ end()

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 = DEFAULT_SLOT_PER_BUCKET>
iterator libcuckoo::cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table::end ( )
inline

Returns an iterator past the end of the table.

Returns
an iterator past the end of the table

◆ 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 = DEFAULT_SLOT_PER_BUCKET>
template<typename K , typename... Args>
std::pair<iterator, bool> libcuckoo::cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table::insert ( K &&  key,
Args &&...  val 
)
inline

This behaves like the unordered_map::try_emplace method. It will always invalidate all iterators, due to the possibilities of cuckoo hashing and expansion.

◆ is_active()

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 = DEFAULT_SLOT_PER_BUCKET>
bool libcuckoo::cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table::is_active ( ) const
inline

Returns whether the locked table has ownership of the table

Returns
true if it still has ownership, false otherwise

◆ operator[]()

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 = DEFAULT_SLOT_PER_BUCKET>
template<typename K >
T& libcuckoo::cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table::operator[] ( K &&  key)
inline

This function has the same lifetime properties as cuckoohash_map::insert, except that the value is default-constructed, with no parameters, if it is not already in the table.

◆ 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 = DEFAULT_SLOT_PER_BUCKET>
void libcuckoo::cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table::rehash ( size_type  n)
inline

This has the same behavior as cuckoohash_map::rehash, except that we don't return anything.

◆ 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 = DEFAULT_SLOT_PER_BUCKET>
void libcuckoo::cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table::reserve ( size_type  n)
inline

This has the same behavior as cuckoohash_map::reserve, except that we don't return anything.

◆ unlock()

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 = DEFAULT_SLOT_PER_BUCKET>
void libcuckoo::cuckoohash_map< Key, T, Hash, KeyEqual, Allocator, SLOT_PER_BUCKET >::locked_table::unlock ( )
inline

Unlocks the table, thereby freeing the locks on the table, but also invalidating all iterators and table operations with this object. It is idempotent.


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