cds
2.3.2
|
Split-ordered list (template specialization for gc::nogc) More...
#include <cds/intrusive/split_list_nogc.h>
Public Types | |
typedef cds::gc::nogc | gc |
Garbage collector. | |
typedef Traits | traits |
Traits template parameters. | |
typedef cds::opt::v::hash_selector< typename traits::hash >::type | hash |
Hash functor for value_type and all its derivatives that you use. | |
typedef OrderedList | ordered_list |
type of ordered list used as base for split-list | |
typedef ordered_list::value_type | value_type |
type of value stored in the split-list | |
typedef ordered_list::key_comparator | key_comparator |
key comparison functor | |
typedef ordered_list::disposer | disposer |
Node disposer functor. | |
typedef traits::bit_reversal | bit_reversal |
Bit reversal algorithm, see split_list::traits::bit_reversal . | |
typedef traits::item_counter | item_counter |
Item counter type. | |
typedef traits::back_off | back_off |
back-off strategy | |
typedef traits::memory_model | memory_model |
Memory ordering. See cds::opt::memory_model option. | |
typedef traits::stat | stat |
Internal statistics, see spit_list::stat . | |
Public Member Functions | |
SplitListSet () | |
Initialize split-ordered list of default capacity. More... | |
SplitListSet (size_t nItemCount, size_t nLoadFactor=1) | |
Initialize split-ordered list. More... | |
~SplitListSet () | |
Destroys split-list. | |
bool | insert (value_type &val) |
Inserts new node. More... | |
template<typename Func > | |
std::pair< bool, bool > | update (value_type &val, Func func, bool bAllowInsert=true) |
Updates the node. More... | |
template<typename Q > | |
value_type * | contains (Q const &key) |
Checks whether the set contains key . More... | |
template<typename Q , typename Less > | |
value_type * | contains (Q const &key, Less pred) |
Checks whether the set contains key using pred predicate for searching. More... | |
template<typename Q , typename Func > | |
bool | find (Q &key, Func f) |
Finds the key key . More... | |
template<typename Q , typename Less , typename Func > | |
bool | find_with (Q &key, Less pred, Func f) |
Finds the key key with pred predicate for comparing. 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. | |
stat const & | statistics () const |
Returns internal statistics. | |
OrderedList::stat const & | list_statistics () const |
Returns internal statistics for OrderedList . | |
Forward iterators | |
typedef iterator_type< false > | iterator |
Forward iterator. More... | |
typedef iterator_type< true > | const_iterator |
Const forward iterator. More... | |
iterator | begin () |
Returns a forward iterator addressing the first element in a split-list. More... | |
iterator | end () |
Returns an iterator that addresses the location succeeding the last element in a split-list. More... | |
const_iterator | begin () const |
Returns a forward const iterator addressing the first element in a split-list. | |
const_iterator | cbegin () const |
Returns a forward const iterator addressing the first element in a split-list. | |
const_iterator | end () const |
Returns an const iterator that addresses the location succeeding the last element in a split-list. | |
const_iterator | cend () const |
Returns an const iterator that addresses the location succeeding the last element in a split-list. | |
Split-ordered list (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 SplitListSet for description of template parameters. The template parameter OrderedList
should be any gc::nogc-derived ordered list, for example, persistent MichaelList, persistent LazyList
typedef iterator_type<true> cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::const_iterator |
Const forward iterator.
For iterator's features and requirements see iterator
typedef iterator_type<false> cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::iterator |
Forward iterator.
The forward iterator for a split-list has some features:
OrderedList
|
inline |
Initialize split-ordered list of default capacity.
The default capacity is defined in bucket table constructor. See split_list::expandable_bucket_table, split_list::static_ducket_table which selects by split_list::dynamic_bucket_table option.
|
inline |
Initialize split-ordered list.
nItemCount | estimate average of item count |
nLoadFactor | load factor - average item count per bucket. Small integer up to 10, default is 1. |
|
inline |
|
inline |
Clears the set (non-atomic, not thread-safe)
The function unlink all items from the set. The function is not atomic. 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). Therefore, clear
() may be used only for debugging purposes.
For each item the disposer
is called after unlinking.
|
inline |
Checks whether the set contains key
.
The function searches the item with key equal to key
and returns true
if it is found, and false
otherwise.
Note the hash functor specified for class Traits
template parameter should accept a parameter of type Q
that can be not the same as value_type
. Otherwise, you may use contains( Q const&, Less pred )
functions with explicit predicate for key comparing.
|
inline |
Checks whether the set contains key
using pred
predicate for searching.
The function is similar to contains( key )
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 list.
|
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 split-list implementation.
|
inline |
|
inline |
Finds the key key
.
The function searches the item with key equal to key
and calls the functor f
for item found. The interface of Func
functor is:
where item
is the item found, key
is the find
function argument.
The functor can change non-key fields of item
. The functor does not serialize simultaneous access to the set item
. If such access is possible you must provide your own synchronization schema on item level to exclude unsafe item modifications.
Note the hash functor specified for class Traits
template parameter should accept a parameter of type Q
that can be not the same as value_type
.
The function returns true
if key
is found, false
otherwise.
|
inline |
Finds the key key
with pred
predicate for comparing.
The function is an analog of find(Q&, Func) but cmp
is used for key compare. Less
has the interface like std::less
. cmp
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
.
Returns true
if val
is placed into the set, false
otherwise.
|
inline |
Updates the node.
The operation performs inserting or changing data with lock-free manner.
If the item val
is not found in the set, then val
is inserted iff bAllowInsert
is true
. Otherwise, the functor func
is called with item found. The functor signature is:
with arguments:
bNew
- true
if the item has been inserted, false
otherwiseitem
- item of the setval
- argument val
passed into the update()
function If new item has been inserted (i.e. bNew
is true
) then item
and val
arguments refers to the same thing.The functor may change non-key fields of the item
.
Returns std::pair<bool, bool> where first
is true
if operation is successful, second
is true
if new item has been added or false
if the item with key
already is in the list.