Added iterator-based choice function
This commit is contained in:
parent
a6accef426
commit
a0f852d419
@ -31,6 +31,12 @@ namespace sc {
|
||||
return vec[dist(instance()._reng)];
|
||||
}
|
||||
|
||||
template <typename T, typename Iter>
|
||||
T choice(Iter from, Iter to) {
|
||||
std::uniform_int_distribution<int> dist {0, static_cast<int>(to - from) - 1};
|
||||
return *(from + dist(instance()._reng));
|
||||
}
|
||||
|
||||
private:
|
||||
static random singleton;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user