[PATCH] Implement std::experimental::sample
eugenis at google.com
Thu Apr 30 08:58:01 PDT 2015
In http://reviews.llvm.org/D9044#163999, @mclow.lists wrote:
> > The new tests don't test the instability of the reservoir sampling algorithm. Should they?
> Yes - but I won't hold up accepting this because that test is missing.
> The phrase in the standard "stable if and only if"...
Fixed anyway, this is easy.
Comment at: include/experimental/algorithm:85
@@ +84,3 @@
+ return _VSTD_LFTS::__sample(
+ __first, __last, __out, __n, __g,
+ typename iterator_traits<_PopulationIterator>::iterator_category(),
> I think that should forward the RNG: `_VSTD::forward<_UniformRandomNumberGenerator>(__g)`
Comment at: test/std/experimental/algorithms/alg.random.sample/sample.stable.pass.cpp:44
@@ +43,3 @@
+ for (int j = 1; j < kSampleSize; ++j)
+ assert(oa[j] > oa[j - 1]);
> Couldn't this just be a call to `std::is_sorted(first, last)` ?
More information about the cfe-commits