|
cds
2.3.2
|
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 | |
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:
value_type - the type of the item in the bucketiterator - bucket's item iteratorconst_iterator - bucket's item constant iteratordefault_resizing_policy - default resizing policy preferable for the container. By default, the library defines cds::container::striped_set::load_factor_resizing<4> for sequential containers like boost::intrusive::list, and cds::container::striped_set::no_resizing for ordered container like boost::intrusive::set.Insert value val of type Q
Inserts val into the container and, if inserting is successful, calls functor f with val.
The functor signature is:
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
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:
or like a functor:
where arguments are:
bNew - true if the item has been inserted, false otherwiseitem - container's itemval - argument val passed into the update() functionIf 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
Unlink val from the container if val belongs to it.
Erase key
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:
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
The function searches the item with key equal to val and calls the functor f for item found. The interface of Func functor is:
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
Second form calls disposer for each item in the container before clearing.
Get size of bucket
This function may be required by some resizing policy
Iterators
Move item when resizing
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.