|
cds
2.3.2
|
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 | |
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 bucketiterator - bucket's item iteratorconst_iterator - bucket's item constant iteratordefault_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
The function allows to split creating of new item into two part:
val f functor to initialize value-field of the new item.The functor signature is:
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)...
Returns true if inserting successful, false otherwise.
This function should be available only for compiler that supports variadic template and move semantics
Updates item
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:
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() functionThe 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
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:
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 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
Get size of bucket
This function can be required by some resizing policy
Move item when resizing
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.