tgen
Loading...
Searching...
No Matches
Miscellaneous

Miscellaneous generation. More...

Functions

std::vector< long long > tgen::misc::unordered_hack (int size)
 List of integers that force collision on std::unordered_set.
std::string tgen::misc::gen_parenthesis (int size)
 Generates a random valid parenthesis sequence.

Detailed Description

Miscellaneous generation.

Function Documentation

◆ gen_parenthesis()

std::string tgen::misc::gen_parenthesis ( int size)
inline

Generates a random valid parenthesis sequence.

Parameters
sizeSize of the sequence.

Generates a uniformly random parenthesis sequence.

Complexity

O(size).

Examples

// Prints a random parenthesis sequence of size 10.
std::cout << tgen::misc::gen_parenthesis(10) << std::endl;
std::string gen_parenthesis(int size)
Generates a random valid parenthesis sequence.
Definition tgen.h:3353

Definition at line 3353 of file tgen.h.

◆ unordered_hack()

std::vector< long long > tgen::misc::unordered_hack ( int size)
inline

List of integers that force collision on std::unordered_set.

Parameters
sizeSize of the list.

Creates hack for both std::unordered_set and std::unordered_map, forcing quadratic behavior. The hack might not be effective due to differences in C++ implementations.

Note
This function benefits from tgen::set_compiler and tgen::set_cpp_version information.

Complexity

O(size).

Examples

// Creates values that force collision.
std::vector<long long> hack = tgen::misc::unordered_hack(1e6);
std::vector< long long > unordered_hack(int size)
List of integers that force collision on stdunordered_set.
Definition tgen.h:3332

Definition at line 3332 of file tgen.h.