|
tgen
|
String generator. More...

Classes | |
| struct | instance |
| String instance. More... | |
Public Member Functions | |
| str (int size, char value_l='a', char value_r='z') | |
| Creates string generator define by size and range of characters. | |
| str (int size, std::set< char > chars) | |
| Creates string generator define by character set. | |
| template<typename... Args> | |
| str (const std::string ®ex, Args &&...args) | |
| Creates string generator define by regex. | |
| str & | fix (int idx, char character) |
| Restricts generator s.t. character at index is fixed. | |
| str & | equal (int idx_1, int idx_2) |
| Restricts generator s.t. values at two indices are the same. | |
| str & | equal_range (int left, int right) |
| Restricts generator s.t. all values at index range are the same. | |
| str & | palindrome (int left, int right) |
| Restricts generator s.t. range is a palindrome. | |
| str & | palindrome () |
| Restricts generator s.t. string is a palindrome. | |
| str & | distinct (std::set< int > indices) |
| Restricts generator s.t. all characters in index set are distinct. | |
| str & | different (int idx_1, int idx_2) |
| Restricts generator s.t. characters at two indices are different. | |
| str & | distinct () |
| Restricts generator s.t. all characters are distinct. | |
| instance | gen () const |
| Generates a random instance from the set of valid strings. | |
| Public Member Functions inherited from tgen::gen_base< str > | |
| auto | gen_list (int size, Args &&...args) const |
| Generates a list of several generation calls. | |
| auto | gen_until (Pred predicate, int max_tries, Args &&...args) const |
| Generates a random instance from the valid set until a condition is met. | |
| auto | unique (Args &&...args) const |
| Creates unique generator for current generator. | |
Static Public Member Functions | |
| static instance | abacaba (int n) |
| Returns the prefix of the infinite word "abacabad...". | |
| static std::pair< instance, instance > | unsigned_polynomial_hash_hack () |
| Returns two strings that force polynomial hash collision for power-of-two mod. | |
| static std::pair< instance, instance > | polynomial_hash_hack (int alphabet_size, int base, int mod) |
| Returns two strings that force polynomial hash collision given base and mod. | |
| static std::pair< instance, instance > | polynomial_hash_hack (int alphabet_size, std::vector< int > bases, std::vector< int > mods) |
| Returns two strings that force polynomial hash collision given bases and mods. | |
String generator.
Defines a set of strings, subject to restrictions.
A uniformly random tgen::str::instance from this set of strings (that satisfies the restrictions) can be generated with tgen::str::gen.
|
inline |
Creates string generator define by size and range of characters.
| size | Size of the string. |
| value_l | Left endpoint of character range. |
| value_r | Right endpoint of character range. |
Defines a generator of strings of length size with characters in [value_l, value_r].
|
inline |
|
inline |
Creates string generator define by regex.
| regex | Regex. |
| args | Arguments for the regex. |
Defines a generator of strings generated by regex (see Strings), with the given args.
|
inlinestatic |
Returns the prefix of the infinite word "abacabad...".
| n | Length of the prefix. |
O(n).
|
inline |
Restricts generator s.t. characters at two indices are different.
| idx_1 | First index. |
| idx_2 | Second index. |
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
Equivalent to tgen::str::distinct({idx_1, idx_2}).
|
inline |
Restricts generator s.t. all characters are distinct.
Equivalent to tgen::str::distinct({0, 1, ... size-1}).
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inline |
Restricts generator s.t. all characters in index set are distinct.
| indices | Index set. |
| std::runtime_error | if the generator was created from regex (restrictions cannot be added for regex). |
|
inline |
Restricts generator s.t. values at two indices are the same.
| idx_1 | First index. |
| idx_2 | Second index. |
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inline |
Restricts generator s.t. all values at index range are the same.
| left | Left endpoint of index range (inclusive). |
| right | Right endpoint of index range (inclusive). |
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inline |
Restricts generator s.t. character at index is fixed.
| idx | Index. |
| character | Character. |
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inline |
Generates a random instance from the set of valid strings.
| std::runtime_error | if there is no valid string satisfying all restrictions. |
If created from restrictions: O(n log n).
If created from regex: expected linear.
|
inline |
Restricts generator s.t. string is a palindrome.
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inline |
Restricts generator s.t. range is a palindrome.
| left | Left endpoint of the index range (inclusive). |
| right | Right endpoint of the index range (inclusive). |
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inlinestatic |
Returns two strings that force polynomial hash collision given base and mod.
| alphabet_size | Alphabet size. |
| base | Base. |
| mod | Mod. |
Computes two strings that have the same polynomial hash for given base and mod.
Characters are in [a, a + alphabet_size).
Reference:
O(sqrt(mod) log mod).
|
inlinestatic |
Returns two strings that force polynomial hash collision given bases and mods.
| alphabet_size | Alphabet size. |
| bases | Bases. |
| mods | Mods. |
Computes two strings that have the same polynomial hash for given bases and mods, up to 2 (base, mod) pairs.
Characters are in [a, a + alphabet_size).
Reference:
O(sqrt(mod) log^2 mod), with mod = max(mods).
Returns two strings that force polynomial hash collision for power-of-two mod.
Computes two strings that have the same polynomial hash for any base and power-of-two mod (up to 2^64).
Characters are in [a, b].
Reference:
O(1).