libstdc++
GNU C++ library
Loading...
Searching...
No Matches

◆ __random_sample() [1/2]

template<typename _InputIterator, typename _RandomAccessIterator, typename _RandomNumberGenerator, typename _Distance>
_RandomAccessIterator __gnu_cxx::__random_sample ( _InputIterator __first,
_InputIterator __last,
_RandomAccessIterator __out,
_RandomNumberGenerator & __rand,
const _Distance __n )

Definition at line 353 of file ext/algorithm.

357 {
358 // concept requirements
360 _RandomNumberGenerator, _Distance, _Distance>)
361
362 _Distance __m = 0;
363 _Distance __t = __n;
364 for ( ; __first != __last && __m < __n; ++__m, ++__first)
365 __out[__m] = *__first;
366
367 while (__first != __last)
368 {
369 ++__t;
370 _Distance __M = __rand(__t);
371 if (__M < __n)
372 __out[__M] = *__first;
373 ++__first;
374 }
375 return __out + __m;
376 }
#define __glibcxx_function_requires(...)

References __glibcxx_function_requires.