cds  2.2.0
cds::container::SplitListSet< cds::gc::nogc, T, Traits > Class Template Reference

Split-ordered list set (template specialization for gc::nogc) More...

#include <cds/container/split_list_set_nogc.h>

Inheritance diagram for cds::container::SplitListSet< cds::gc::nogc, T, Traits >:
cds::intrusive::SplitListSet< cds::gc::nogc, Traits::ordered_list, Traits >

Public Types

typedef cds::gc::nogc gc
 Garbage collector.
 
typedef T value_type
 type of value to be stored in the list
 
typedef Traits traits
 List traits.
 
typedef maker::ordered_list ordered_list
 Underlying ordered list class.
 
typedef base_class::key_comparator key_comparator
 key comparison functor
 
typedef base_class::hash hash
 Hash functor for value_type and all its derivatives that you use.
 
typedef base_class::item_counter item_counter
 Item counter type.
 
typedef base_class::stat stat
 Internal statistics.
 

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...
 
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 created from args. More...
 
template<typename Q >
std::pair< iterator, bool > update (Q const &key, bool bAllowInsert=true)
 Updates the item. More...
 
template<typename Q >
iterator contains (Q const &key)
 Checks whether the set contains key. More...
 
template<typename Q , typename Less >
iterator contains (Q const &key, Less pred)
 Checks whether the set contains key using pred predicate for searching. More...
 
void clear ()
 Clears the set (not atomic, for debugging purposes only)
 
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.
 
ordered_list::stat const & list_statistics () const
 Returns internal statistics for ordered_list.
 

Forward iterators

typedef iterator_type< false > iterator
 Forward iterator. More...
 
typedef iterator_type< true > const_iterator
 Const forward iterator.
 
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...
 
const_iterator begin () const
 Returns a forward const iterator addressing the first element in a set.
 
const_iterator cbegin () const
 Returns a forward const iterator addressing the first element in a set.
 
const_iterator end () const
 Returns an const iterator that addresses the location succeeding the last element in a set.
 
const_iterator cend () const
 Returns an const iterator that addresses the location succeeding the last element in a set.
 

Additional Inherited Members

- Protected Types inherited from cds::intrusive::SplitListSet< cds::gc::nogc, Traits::ordered_list, Traits >
typedef cds::gc::nogc gc
 Garbage collector.
 
typedef Traits traits
 Set traits.
 
typedef Traits::ordered_list ordered_list
 type of ordered list used as a 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 cds::opt::v::hash_selector< typename traits::hash >::type hash
 Hash functor for value_type and all its derivatives you use.
 
typedef traits::item_counter item_counter
 Item counter type.
 
typedef traits::back_off back_off
 back-off strategy for spinning
 
typedef traits::memory_model memory_model
 Memory ordering. See cds::opt::memory_model option.
 
typedef traits::stat stat
 Internal statistics, see spit_list::stat.
 
typedef ordered_list::guarded_ptr guarded_ptr
 Guarded pointer.
 
typedef iterator_type< false > iterator
 Forward iterator. More...
 
typedef iterator_type< true > const_iterator
 Const forward iterator. More...
 
- Protected Member Functions inherited from cds::intrusive::SplitListSet< cds::gc::nogc, Traits::ordered_list, Traits >
 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 set.
 
bool insert (value_type &val)
 Inserts new node. More...
 
bool insert (value_type &val, Func f)
 Inserts new node. More...
 
std::pair< bool, bool > update (value_type &val, Func func, bool bAllowInsert=true)
 Updates the node. More...
 
std::pair< bool, bool > upsert (value_type &val, bool bAllowInsert=true)
 Inserts or updates the node (only for IterableList) More...
 
bool unlink (value_type &val)
 Unlinks the item val from the set. More...
 
bool erase (Q const &key)
 Deletes the item from the set. More...
 
bool erase (Q const &key, Func f)
 Deletes the item from the set. More...
 
bool erase_with (const Q &key, Less pred)
 Deletes the item from the set with comparing functor pred. More...
 
bool erase_with (Q const &key, Less pred, Func f)
 Deletes the item from the set with comparing functor pred. More...
 
guarded_ptr extract (Q const &key)
 Extracts the item with specified key. More...
 
guarded_ptr extract_with (Q const &key, Less pred)
 Extracts the item using compare functor pred. More...
 
bool find (Q &key, Func f)
 Finds the key key. More...
 
iterator find (Q &key)
 Finds key and returns iterator pointed to the item found (only for IterableList) More...
 
bool find_with (Q &key, Less pred, Func f)
 Finds the key key with pred predicate for comparing. More...
 
iterator find_with (Q &key, Less pred)
 Finds key using pred predicate and returns iterator pointed to the item found (only for IterableList) More...
 
bool contains (Q const &key)
 Checks whether the set contains key. More...
 
bool contains (Q const &key, Less pred)
 Checks whether the set contains key using pred predicate for searching. More...
 
guarded_ptr get (Q const &key)
 Finds the key key and return the item found. More...
 
guarded_ptr get_with (Q const &key, Less pred)
 Finds the key key and return the item found. More...
 
size_t size () const
 Returns item count in the set.
 
bool empty () const
 Checks if the set is empty. More...
 
void clear ()
 Clears the set (non-atomic) More...
 
stat const & statistics () const
 Returns internal statistics.
 
Traits::ordered_list ::stat const & list_statistics () const
 Returns internal statistics for OrderedList.
 
iterator begin ()
 Returns a forward iterator addressing the first element in a split-list. More...
 
const_iterator begin () const
 Returns a forward const iterator addressing the first element in a split-list.
 
iterator end ()
 Returns an iterator that addresses the location succeeding the last element in a split-list. More...
 
const_iterator end () const
 Returns an const iterator that addresses the location succeeding the last element in a split-list.
 
const_iterator cbegin () const
 Returns a forward const iterator addressing the first 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.
 
- Static Protected Attributes inherited from cds::intrusive::SplitListSet< cds::gc::nogc, Traits::ordered_list, Traits >
static constexpr const size_t c_nHazardPtrCount
 Count of hazard pointer required.
 

Detailed Description

template<class T, class Traits = split_list::traits>
class cds::container::SplitListSet< cds::gc::nogc, T, Traits >

Split-ordered list set (template specialization for gc::nogc)

This specialization is so-called append-only container when no item reclamation may be performed. The class does not support deleting of list item.

See SplitListSet for description of template parameters.

Warning
Many member functions return an iterator pointing to an item. The iterator can be used to set up field of the item, but you should provide an exclusive access to it, see insert item troubleshooting.

Member Typedef Documentation

§ iterator

template<class T , class Traits = split_list::traits>
typedef iterator_type<false> cds::container::SplitListSet< cds::gc::nogc, T, Traits >::iterator

Forward iterator.

The forward iterator for split-list is based on OrderedList forward iterator and has some features:

  • it has no post-increment operator
  • it iterates items in unordered fashion

The iterator interface:

class iterator {
public:
// Default constructor
// Copy construtor
iterator( iterator const& src );
// Dereference operator
value_type * operator ->() const;
// Dereference operator
value_type& operator *() const;
// Preincrement operator
iterator& operator ++();
// Assignment operator
iterator& operator = (iterator const& src);
// Equality operators
bool operator ==(iterator const& i ) const;
bool operator !=(iterator const& i ) const;
};

Constructor & Destructor Documentation

§ SplitListSet() [1/2]

template<class T , class Traits = split_list::traits>
cds::container::SplitListSet< cds::gc::nogc, T, Traits >::SplitListSet ( )
inline

Initialize split-ordered list of default capacity.

The default capacity is defined in bucket table constructor. See intrusive::split_list::expandable_bucket_table, intrusive::split_list::static_bucket_table which selects by split_list::dynamic_bucket_table option.

§ SplitListSet() [2/2]

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

Initialize split-ordered list.

Parameters
nItemCountestimated 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 T , class Traits = split_list::traits>
iterator cds::container::SplitListSet< cds::gc::nogc, T, Traits >::begin ( )
inline

Returns a forward iterator addressing the first element in a set.

For empty set

begin() == end()

§ contains() [1/2]

template<class T , class Traits = split_list::traits>
template<typename Q >
iterator cds::container::SplitListSet< cds::gc::nogc, T, Traits >::contains ( Q const &  key)
inline

Checks whether the set contains key.

The function searches the item with key equal to key and returns an iterator pointed to item found and end() otherwise

§ contains() [2/2]

template<class T , class Traits = split_list::traits>
template<typename Q , typename Less >
iterator cds::container::SplitListSet< cds::gc::nogc, T, Traits >::contains ( Q const &  key,
Less  pred 
)
inline

Checks whether the set contains key using pred predicate for searching.

The function is an analog of contains( key ) but pred is used for key comparing. Less functor has the interface like std::less. pred must imply the same element order as the comparator used for building the set.

§ emplace()

template<class T , class Traits = split_list::traits>
template<typename... Args>
iterator cds::container::SplitListSet< cds::gc::nogc, T, Traits >::emplace ( Args &&...  args)
inline

Inserts data of type value_type created from args.

Return an iterator pointing to inserted item if success end() otherwise

§ empty()

template<class T , class Traits = split_list::traits>
bool cds::container::SplitListSet< cds::gc::nogc, T, 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 set implementation.

§ end()

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

Returns an iterator that addresses the location succeeding the last element in a set.

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 set. For empty set

begin() == end()

§ insert()

template<class T , class Traits = split_list::traits>
template<typename Q >
iterator cds::container::SplitListSet< cds::gc::nogc, T, Traits >::insert ( const Q &  val)
inline

Inserts new node.

The function inserts val in the set if it does not contain an item with key equal to val. The value_type should be constructible from a value of type Q.

Return an iterator pointing to inserted item if success end() otherwise

§ update()

template<class T , class Traits = split_list::traits>
template<typename Q >
std::pair<iterator, bool> cds::container::SplitListSet< cds::gc::nogc, T, Traits >::update ( Q const &  key,
bool  bAllowInsert = true 
)
inline

Updates the item.

If key is not in the set and bAllowInsert is true, the function inserts a new item. Otherwise, the function returns an iterator pointing to the item found.

Returns std::pair<iterator, bool> where first is an iterator pointing to item found or inserted (if inserting is not allowed and key is not found, the iterator will be end()),

second is true if new item has been added or false if the item already is in the set.

Warning
If the set is based on MichaelList,

see insert item troubleshooting. LazyList as the base 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:43 by Doxygen 1.8.12