Algorithms library

Header <experimental/algorithm> synopsis

#include <algorithm>

namespace std::experimental::inline fundamentals_v3 {

  
  template<class PopulationIterator, class SampleIterator, class Distance>
  SampleIterator sample(PopulationIterator first, PopulationIterator last,
                        SampleIterator out, Distance n);

  
  template<class RandomAccessIterator>
  void shuffle(RandomAccessIterator first, RandomAccessIterator last);

} // namespace std::experimental::inline fundamentals_v3

Sampling

template<class PopulationIterator, class SampleIterator, class Distance> SampleIterator sample(PopulationIterator first, PopulationIterator last, SampleIterator out, Distance n); Equivalent to:
return ::std::sample(first, last, out, n, g);
where g denotes the per-thread engine (). To the extent that the implementation of this function makes use of random numbers, the object g serves as the implementation’s source of randomness.

Shuffle

template<class RandomAccessIterator> void shuffle(RandomAccessIterator first, RandomAccessIterator last); RandomAccessIterator meets the Cpp17ValueSwappable requirements (). Permutes the elements in the range [first,last) such that each possible permutation of those elements has equal probability of appearance. Exactly (last - first) - 1 swaps. To the extent that the implementation of this function makes use of random numbers, the per-thread engine () serves as the implementation's source of randomness.