cds  2.3.2
cds::intrusive::striped_set::adapt< Container, Options > Class Template Reference

Default adapter for intrusive striped/refinable hash set. More...

#include <cds/intrusive/striped_set/adapter.h>

Public Types

typedef Container type
 adapted container type
 
typedef type::value_type value_type
 value type stored in the container
 

Detailed Description

template<typename Container, typename... Options>
class cds::intrusive::striped_set::adapt< Container, Options >

Default adapter for intrusive striped/refinable hash set.

By default, the metafunction does not make any transformation for container type Container. Container should provide interface suitable for the hash set.

The Options template argument contains option pack that will be passed to cds::intrusive::StripedSet.

Bucket interface

The result of metafunction is a container (a bucket) that should support the following interface:

Public typedefs that the bucket should provide:

Insert value val of type Q

template <typename Func> bool insert( value_type& val, Func f ) ;

Inserts val into the container and, if inserting is successful, calls functor f with val.

The functor signature is:

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

where item is the item inserted.

The user-defined functor f is called only if the inserting is success.


Updates the item in the container

template <typename Func> std::pair<bool, bool> update( value_type& val, Func f, bool bAllowInsert = true )

The operation performs inserting or changing data.

If the val key not found in the container, then val is inserted iff bAllowInsert is true. Otherwise, the functor f is called with the item found.

The Func functor has the following interface:

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

or like a functor:

struct functor {
void operator()( bool bNew, value_type& item, value_type& val );
};

where arguments are:

  • bNew - true if the item has been inserted, false otherwise
  • item - container's item
  • val - argument val passed into the update() function

If val has been inserted (i.e. bNew == true) then item and val are the same element: &item == &val. Otherwise, they are different.

The functor can 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 val key already exists.


Unlink an item

bool unlink( value_type& val )

Unlink val from the container if val belongs to it.


Erase key

template <typename Q, typename Func> bool erase( Q const& key, Func f )

The function searches an item with key key, calls f functor and erases the item. If key is not found, the functor is not called.

The functor Func interface is:

struct functor {
void operator()(value_type& val);
};

The type Q can differ from value_type of items storing in the container. Therefore, the value_type should be comparable with type Q.

Return true if key is found and deleted, false otherwise


Find the key val

template <typename Q, typename Func> bool find( Q& val, Func f )
template <typename Q, typename Compare, typename Func> bool find( Q& val, Compare cmp, Func f )

The function searches the item with key equal to val and calls the functor f for item found. The interface of Func functor is:

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

where item is the item found, val is the find function argument.

The functor can change non-key fields of item. The val argument may be non-const since it can be used as f functor destination i.e., the functor can modify both arguments.

The type Q can differ from value_type of items storing in the container. Therefore, the value_type should be comparable with type Q.

The first form uses default compare function used for key ordering. The second form allows to point specific Compare functor cmp that can compare value_typwe and Q type. The interface of Compare is the same as std::less.

The function returns true if val is found, false otherwise.


Clears the container

void clear()
template <typename Disposer> void clear( Disposer disposer )

Second form calls disposer for each item in the container before clearing.


Get size of bucket

size_t size() const

This function may be required by some resizing policy


Iterators

iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;

Move item when resizing

void move_item( adapted_container& from, iterator it )

This helper function is invented for the set resizing when the item pointed by it iterator is copied from old bucket from to a new bucket pointed by this.



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

cds 2.3.2 Developed by Maxim Khizhinsky aka khizmax and other contributors 2007 - 2017
Autogenerated Sun Dec 31 2017 12:10:48 by Doxygen 1.8.13