|
cds
1.4.0
|
Michael's hash set (template specialization for gc::nogc) More...
#include <cds/container/michael_set_nogc.h>
Public Types | |
| typedef OrderedList | bucket_type |
| type of ordered list used as a bucket implementation | |
| typedef Traits | options |
| Traits template parameters. | |
| typedef bucket_type::value_type | value_type |
| type of value stored in the list | |
| typedef gc::nogc | gc |
| Garbage collector. | |
| typedef bucket_type::key_comparator | key_comparator |
| key comparision functor | |
|
typedef cds::opt::v::hash_selector < typename options::hash > ::type | hash |
| Hash functor for value_type and all its derivatives that you use. | |
| typedef options::item_counter | item_counter |
| Item counter type. | |
|
typedef cds::details::Allocator < bucket_type, typename options::allocator > | bucket_table_allocator |
| Bucket table allocator. | |
| typedef michael_set::details::iterator < bucket_type, false > | iterator |
| Forward iterator. More... | |
| typedef michael_set::details::iterator < bucket_type, true > | const_iterator |
| Const forward iterator. More... | |
Public Member Functions | |
| iterator | begin () |
| Returns a forward iterator addressing the first element in a set. More... | |
| iterator | end () |
| Returns an iterator that addresses the location succeeding the last element in a set. More... | |
| MichaelHashSet (size_t nMaxItemCount, size_t nLoadFactor) | |
| Initialize hash set. More... | |
| ~MichaelHashSet () | |
| Clear hash set and destroy it. | |
| template<typename Q > | |
| iterator | insert (const Q &val) |
| Inserts new node. More... | |
| template<typename... Args> | |
| iterator | emplace (Args &&...args) |
Inserts data of type value_type constructed with std::forward<Args>(args)... More... | |
| template<typename Q > | |
| std::pair< iterator, bool > | ensure (const Q &val) |
Ensures that the item val exists in the set. More... | |
| template<typename Q > | |
| iterator | find (Q const &key) |
Find the key key. More... | |
| template<typename Q , typename Less > | |
| iterator | find_with (Q const &key, Less pred) |
Finds the key val using pred predicate for searching. More... | |
| void | clear () |
| Clears the set (non-atomic, not thread-safe) More... | |
| bool | empty () const |
| Checks if the set is empty. More... | |
| size_t | size () const |
| Returns item count in the set. | |
| size_t | bucket_count () const |
| Returns the size of hash table. More... | |
| const_iterator | begin () const |
| Returns a forward const iterator addressing the first element in a set. | |
| const_iterator | cbegin () |
| const_iterator | end () const |
| Returns an const iterator that addresses the location succeeding the last element in a set. | |
| const_iterator | cend () |
Protected Member Functions | |
| template<typename Q > | |
| size_t | hash_value (const Q &key) const |
Calculates hash value of key. | |
| template<typename Q > | |
| bucket_type & | bucket (const Q &key) |
Returns the bucket (ordered list) for key. | |
Protected Attributes | |
| item_counter | m_ItemCounter |
| Item counter. | |
| hash | m_HashFunctor |
| Hash functor. | |
| bucket_type * | m_Buckets |
| bucket table | |
Private Member Functions | |
| const_iterator | get_const_begin () const |
| const_iterator | get_const_end () const |
Michael's hash set (template specialization for gc::nogc)
This specialization is intended for so-called persistent usage when no item reclamation may be performed. The class does not support deleting of list item.
See MichaelHashSet for description of template parameters. The template parameter OrderedList should be any gc::nogc-derived ordered list, for example, persistent MichaelList.
The interface of the specialization is a slightly different.
| typedef michael_set::details::iterator< bucket_type, true > cds::container::MichaelHashSet< gc::nogc, OrderedList, Traits >::const_iterator |
Const forward iterator.
For iterator's features and requirements see iterator
| typedef michael_set::details::iterator< bucket_type, false > cds::container::MichaelHashSet< gc::nogc, OrderedList, Traits >::iterator |
Forward iterator.
The forward iterator for Michael's set is based on OrderedList forward iterator and has some features:
|
inline |
Initialize hash set.
See MichaelHashSet ctor for explanation
| nMaxItemCount | estimation of max item count in the hash set |
| nLoadFactor | load factor: estimation of max number of items in the bucket |
|
inline |
|
inline |
Returns the size of hash table.
Since MichaelHashSet cannot dynamically extend the hash table size, the value returned is an constant depending on object initialization parameters; see MichaelHashSet::MichaelHashSet for explanation.
|
inline |
Clears the set (non-atomic, not thread-safe)
The function deletes all items from the set. The function is not atomic and even not thread-safe. It cleans up each bucket and then resets the item counter to zero. If there are a thread that performs insertion while clear is working the result is undefined in general case: empty() may return true but the set may contain item(s).
|
inline |
Inserts data of type value_type constructed with std::forward<Args>(args)...
Return an iterator pointing to inserted item if success end() otherwise
This function is available only for compiler that supports variadic template and move semantics
|
inline |
Checks if the set is empty.
Emptiness is checked by item counting: if item count is zero then the set is empty. Thus, the correct item counting feature is an important part of Michael's set implementation.
|
inline |
|
inline |
Ensures that the item val exists in the set.
The operation inserts new item if the key val is not found in the set. Otherwise, the function returns an iterator that points to item found.
Returns std::pair<iterator, bool> where first is an iterator pointing to item found or inserted, second is true if new item has been added or false if the item already is in the set.
|
inline |
Find the key key.
The function searches the item with key equal to key and returns an iterator pointed to item found if the key is found, and end() otherwise
|
inline |
Finds the key val using pred predicate for searching.
The function is an analog of find(Q const&) but pred is used for key comparing. Less functor has the interface like std::less. Less must imply the same element order as the comparator used for building the set.
|
inline |
Inserts new node.
The function inserts val in the set if it does not contain an item with key equal to val.
Return an iterator pointing to inserted item if success, otherwise end()