cds  2.2.0
cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits > Class Template Reference

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::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_typecontains (Q const &key)
 Checks whether the set contains key. More...
 
template<typename Q , typename Less >
value_typecontains (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.
 

Detailed Description

template<class OrderedList, class Traits = split_list::traits>
class cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >

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

Member Typedef Documentation

§ const_iterator

template<class OrderedList , class Traits = split_list::traits>
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

§ iterator

template<class OrderedList , class Traits = split_list::traits>
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:

  • it has no post-increment operator
  • it depends on iterator of underlying OrderedList

Constructor & Destructor Documentation

§ SplitListSet() [1/2]

template<class OrderedList , class Traits = split_list::traits>
cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::SplitListSet ( )
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.

§ SplitListSet() [2/2]

template<class OrderedList , class Traits = split_list::traits>
cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::SplitListSet ( size_t  nItemCount,
size_t  nLoadFactor = 1 
)
inline

Initialize split-ordered list.

Parameters
nItemCountestimate average of item count
nLoadFactorload factor - average item count per bucket. Small integer up to 10, default is 1.

Member Function Documentation

§ begin()

template<class OrderedList , class Traits = split_list::traits>
iterator cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::begin ( )
inline

Returns a forward iterator addressing the first element in a split-list.

For empty list

begin() == end()

§ clear()

template<class OrderedList , class Traits = split_list::traits>
void cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::clear ( )
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.

§ contains() [1/2]

template<class OrderedList , class Traits = split_list::traits>
template<typename Q >
value_type* cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::contains ( Q const &  key)
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.

§ contains() [2/2]

template<class OrderedList , class Traits = split_list::traits>
template<typename Q , typename Less >
value_type* cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::contains ( Q const &  key,
Less  pred 
)
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.

§ empty()

template<class OrderedList , class Traits = split_list::traits>
bool cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::empty ( ) const
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.

§ end()

template<class OrderedList , class Traits = split_list::traits>
iterator cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::end ( )
inline

Returns an iterator that addresses the location succeeding the last element in a split-list.

Do not use the value returned by end function to access any item.

The returned value can be used only to control reaching the end of the split-list. For empty list

begin() == end()

§ find()

template<class OrderedList , class Traits = split_list::traits>
template<typename Q , typename Func >
bool cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::find ( Q &  key,
Func  f 
)
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:

struct functor {
void operator()( value_type& item, Q& key );
};

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.

§ find_with()

template<class OrderedList , class Traits = split_list::traits>
template<typename Q , typename Less , typename Func >
bool cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::find_with ( Q &  key,
Less  pred,
Func  f 
)
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.

§ insert()

template<class OrderedList , class Traits = split_list::traits>
bool cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::insert ( value_type val)
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.

§ update()

template<class OrderedList , class Traits = split_list::traits>
template<typename Func >
std::pair<bool, bool> cds::intrusive::SplitListSet< cds::gc::nogc, OrderedList, Traits >::update ( value_type val,
Func  func,
bool  bAllowInsert = true 
)
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:

void func( bool bNew, value_type& item, value_type& val );

with arguments:

  • bNew - true if the item has been inserted, false otherwise
  • item - item of the set
  • val - 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.

Warning
For MichaelList as the bucket see insert item troubleshooting. LazyList provides exclusive access to inserted item and does not require any node-level synchronization.

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

cds 2.2.0 Developed by Maxim Khizhinsky aka khizmax 2007 - 2017
Autogenerated Wed Jan 4 2017 08:49:52 by Doxygen 1.8.12