13 template<concepts::InputIterator It, concepts::SentinelFor<It> Sent, concepts::WeaklyIncrementable Out,
21 using Param = Distribution::Param;
23 auto distribution = Distribution {};
34 if (distribution(generator, Param(0, --
count)) < to_sample) {
47 SSizeType reservoir_size = 0;
48 for (; first != last && reservoir_size < n; ++first, ++reservoir_size) {
49 out[reservoir_size] = *first;
53 for (
auto size_so_far = reservoir_size; first != last; ++first, ++size_so_far) {
54 auto chosen_index = distribution(generator, Param(0, size_so_far));
55 if (chosen_index < n) {
56 out[chosen_index] = *first;