From 1ccd3488a0c946b2ad4c0e525d91dcf96d1ca707 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Wed, 4 Dec 2019 17:44:38 -0800 Subject: helper func + bug fix --- Source/Random.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Source/Random.h') diff --git a/Source/Random.h b/Source/Random.h index e809c1e..36b6dc1 100644 --- a/Source/Random.h +++ b/Source/Random.h @@ -6,6 +6,20 @@ public: static void SetSeed(int seed); static int RandInt(int min, int max); + template + static std::vector SelectFromSet(std::vector set, size_t count) { + size_t setSize = set.size(); + assert(count < setSize); + std::vector selection; + for (int i=0; i(setSize - 1)); + selection.emplace_back(set[index]); + set[index] = set[setSize-1]; + setSize--; + } + return selection; + } + private: static uint32_t s_seed; }; -- cgit 1.4.1