Honeycomb  0.1
Component-Model Framework
Classes | Public Types | Public Member Functions | List of all members
honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual > Class Template Reference

Lock-free unordered map. Uses auto-expanding freelist allocator so memory is only reclaimed upon destruction. More...

#include <UnorderedMap.h>

Inheritance diagram for honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >:
Inheritance graph
[legend]
Collaboration diagram for honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >:
Collaboration graph
[legend]

Public Types

typedef T value_type
 

Public Member Functions

 UnorderedMap (szt capacity=0, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual())
 
 ~UnorderedMap ()
 
void reserve (szt capacity)
 Ensure that enough storage is allocated for a number of elements. More...
 
szt capacity () const
 The number of elements for which storage is allocated. More...
 
template<class Pair >
bool insert (Pair &&pair)
 Insert new key-value pair into the map. Returns true on success, false if element with key already exists. More...
 
bool erase (const Key &key, optional< T & > val=optnull)
 Remove element with key from the map and copy its value into val. Returns true on success, false if not found. More...
 
void clear ()
 Remove all elements. More...
 
bool find (const Key &key, optional< T & > val=optnull) const
 Find element with key and copy its value into val. Returns true on success, false if not found. More...
 
szt count (const Key &key) const
 Return number of elements with matching key (either 0 or 1) More...
 
bool empty () const
 Check whether the map does not contain any elements. More...
 
szt size () const
 The number of elements in the map. More...
 
szt bucket_count () const
 The number of buckets. A bucket is a slot in the internal hash table to which elements are assigned based on their key hash. More...
 
float load_factor () const
 The current load factor. The load factor is the ratio between the number of elements and the number of buckets. More...
 
float max_load_factor () const
 Get the max load factor. The internal hash table will expand when the load factor is above the max load factor. More...
 
void max_load_factor (float f)
 Set the max load factor. More...
 

Detailed Description

template<class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
class honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >

Lock-free unordered map. Uses auto-expanding freelist allocator so memory is only reclaimed upon destruction.

Based on the paper: "Split-Ordered Lists - Lock-free Resizable Hash Tables", Shalev, Shavit - 2006

Member Typedef Documentation

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
typedef T honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::value_type

Constructor & Destructor Documentation

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::UnorderedMap ( szt  capacity = 0,
const Hash &  hash = Hash(),
const KeyEqual &  equal = KeyEqual() 
)
inline
template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::~UnorderedMap ( )
inline

Member Function Documentation

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
szt honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::bucket_count ( ) const
inline

The number of buckets. A bucket is a slot in the internal hash table to which elements are assigned based on their key hash.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
szt honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::capacity ( ) const
inline

The number of elements for which storage is allocated.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
void honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::clear ( )
inline

Remove all elements.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
szt honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::count ( const Key &  key) const
inline

Return number of elements with matching key (either 0 or 1)

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
bool honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::empty ( ) const
inline

Check whether the map does not contain any elements.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
bool honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::erase ( const Key &  key,
optional< T & >  val = optnull 
)
inline

Remove element with key from the map and copy its value into val. Returns true on success, false if not found.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
bool honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::find ( const Key &  key,
optional< T & >  val = optnull 
) const
inline

Find element with key and copy its value into val. Returns true on success, false if not found.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
template<class Pair >
bool honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::insert ( Pair &&  pair)
inline

Insert new key-value pair into the map. Returns true on success, false if element with key already exists.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
float honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::load_factor ( ) const
inline

The current load factor. The load factor is the ratio between the number of elements and the number of buckets.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
float honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::max_load_factor ( ) const
inline

Get the max load factor. The internal hash table will expand when the load factor is above the max load factor.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
void honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::max_load_factor ( float  f)
inline

Set the max load factor.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
void honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::reserve ( szt  capacity)
inline

Ensure that enough storage is allocated for a number of elements.

template<class Key , class T , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
szt honey::lockfree::UnorderedMap< Key, T, Hash, KeyEqual >::size ( ) const
inline

The number of elements in the map.


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