|
dasmig-core 1.2.0
Shared random engine, distributions and data tiers for the dasmig generator libraries
|
Makes a batch unique by a key (an email, a username, ...). More...
#include <batch.hpp>
Public Member Functions | |
| std::size_t | max_attempts () const noexcept |
| Attempts per item, including the first. | |
| std::type_index | type () const noexcept |
| The item type the rule was made for. | |
| std::string | key_of (const void *item) const |
| The key of an item. | |
Static Public Member Functions | |
| template<typename T , typename Key > | |
| static unique_rule | by (Key key, std::size_t max_attempts=100) |
Unique by key. | |
Makes a batch unique by a key (an email, a username, ...).
Items are generated, then checked in index order; an item whose key was already produced earlier in the same call is generated again with the next attempt seed (see attempt_seed()) until it is new or the attempts run out. The outcome is the same for any thread count. Uniqueness holds within one call: two batches that are concatenated are not checked against each other.
|
inlinestatic |
Unique by key.
| T | The item type the batch produces. |
| Key | Callable taking const T& and returning something convertible to std::string. |
| key | Extracts the key. |
| max_attempts | Attempts per item, including the first (at least 1). |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |