diff --git a/array.h b/array.h index 0b9ab9d..9cd45d5 100644 --- a/array.h +++ b/array.h @@ -234,7 +234,7 @@ GenericArray GenericArray::choice(size_t count) const { size_t n = size(); - std::unordered_map used; + std::unordered_map used; std::vector res; for (size_t i = 0; i < count; ++i) { size_t oldValue = used.count(n-i-1) ? used[n-i-1] : n-i-1; @@ -246,6 +246,15 @@ GenericArray GenericArray::choice(size_t count) const { return subseq(res); } +template +GenericArray GenericArray::choiceWithRepetition(size_t count) const { + GenericArray res(count); + for (T& t: res) { + t = choice(); + } + return res; +} + template GenericArray& GenericArray::operator+=(const GenericArray& other) { insert(end(), other.begin(), other.end());