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

Default adapter for hash set. More...

#include <cds/container/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::container::striped_set::adapt< Container, Options >

Default adapter for 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 a list of options that has been passed to cds::container::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:

  • value_type - the type of the item in the bucket
  • iterator - bucket's item iterator
  • const_iterator - bucket's item constant iterator
  • default_resizing_policy - defalt resizing policy preferable for the container. By default, the library defines striped_set::load_factor_resizing<4> for sequential containers like std::list, std::vector, and striped_set::no_resizing for ordered container like std::set, std::unordered_set.

Insert value val of type Q

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

The function allows to split creating of new item into two part:

  • create item with key only from val
  • try to insert new item into the container
  • if inserting is success, calls f functor to initialize value-field of the new item.

The functor signature is:

void func( value_type& item );

where item is the item inserted.

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

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


Inserts data of type value_type constructed with std::forward<Args>(args)...

template <typename... Args> bool emplace( Args&&... args ) ;

Returns true if inserting successful, false otherwise.

This function should be available only for compiler that supports variadic template and move semantics


Updates item

template <typename Q, typename Func> std::pair<bool, bool> update( const Q& val, Func func, bool bAllowInsert )

The operation performs inserting or changing data.

If the val key not found in the container, then the new item created from val is inserted iff bAllowInsert is true. Otherwise, the functor func is called with the item found. The Func functor has interface:

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

or like a functor:

struct my_functor {
void operator()( bool bNew, value_type& item, const Q& 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

The functor can change non-key fields of the item.

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

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.


Delete key

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

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

The functor Func interface is:

struct extractor {
void operator()(value_type const& 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 )

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 is 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 function returns true if val is found, false otherwise.


Clears the container

void clear()

Get size of bucket

size_t size() const

This function can be required by some resizing policy


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 an 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:34 by Doxygen 1.8.13