diff --git a/include/utils/random/generator.h b/include/utils/random/generator.h index bc2140068..b503e7635 100644 --- a/include/utils/random/generator.h +++ b/include/utils/random/generator.h @@ -18,7 +18,6 @@ class RandomGenerator { public: RandomGenerator(Distribution dist) : gen_(device_()), dist_(dist) {} - }; class StringGenerator @@ -30,45 +29,27 @@ class StringGenerator std::string next(int size) { std::string random_string; + random_string.reserve(size); for (int i = 0; i < size; i++) random_string += (dist_(gen_) + '\0'); + return random_string; } - }; template -class IntegerGenerator : public RandomGenerator { - +class NumberGenerator : public RandomGenerator { public: - IntegerGenerator(DistributionRangeType start, DistributionRangeType end) : - RandomGenerator(Distribution(start, end)){} - - int next() { - return this->dist_(this->gen_); - - } - -}; - -template -class DecimalGenerator : public RandomGenerator { - - public: - DecimalGenerator(DistributionRangeType start, DistributionRangeType end) : - RandomGenerator(Distribution(start, end)) {} - - auto next() { - return this->dist_(this->gen_); - } + NumberGenerator(DistributionRangeType start, DistributionRangeType end) + : RandomGenerator(Distribution(start, end)) {} + auto next() { return this->dist_(this->gen_); } }; template auto generate_vector(RandomGenerator& gen, int size) { - std::vector elements(size); - for (int i = 0; i < size; i++) - elements[i] = gen.next(); + std::vector elements(size); + for (int i = 0; i < size; i++) elements[i] = gen.next(); return elements; }