Container-based version of the <algorithm> std::sample() function to randomly sample elements from the container without replacement using a gen() uniform random number generator and write them to an iterator range.
Declared in <absl/algorithm/container.h>
template<
typename C,
typename OutputIterator,
typename Distance,
typename UniformRandomBitGenerator>
OutputIterator
c_sample(
C const& c,
OutputIterator result,
Distance n,
UniformRandomBitGenerator&& gen);
An iterator to the end of the written range in the output.
| Name | Description |
|---|---|
| c | The container to sample from. |
| result | The output iterator receiving the sampled elements. |
| n | The number of elements to sample. |
| gen | The uniform random bit generator driving the sampling. |