|
245 | 245 | ForwardIterator2 first2, ForwardIterator2 last2,
|
246 | 246 | BinaryPredicate pred);
|
247 | 247 |
|
| 248 | + // \ref{alg.search}, search: |
248 | 249 | template<class ForwardIterator1, class ForwardIterator2>
|
249 | 250 | ForwardIterator1 search(
|
250 | 251 | ForwardIterator1 first1, ForwardIterator1 last1,
|
|
284 | 285 | Size count, const T& value,
|
285 | 286 | BinaryPredicate pred);
|
286 | 287 |
|
| 288 | + template <class ForwardIterator, class Searcher> |
| 289 | + ForwardIterator search(ForwardIterator first, ForwardIterator last, |
| 290 | + const Searcher &searcher); |
| 291 | + |
287 | 292 | // \ref{alg.modifying.operations}, modifying sequence operations:
|
288 | 293 | // \ref{alg.copy}, copy:
|
289 | 294 | template<class InputIterator, class OutputIterator>
|
|
512 | 517 | ForwardIterator first, ForwardIterator middle,
|
513 | 518 | ForwardIterator last, OutputIterator result);
|
514 | 519 |
|
| 520 | + // \ref{alg.random.sample}, sample: |
| 521 | + template<class PopulationIterator, class SampleIterator, |
| 522 | + class Distance, class UniformRandomNumberGenerator> |
| 523 | + SampleIterator sample(PopulationIterator first, PopulationIterator last, |
| 524 | + SampleIterator out, Distance n, |
| 525 | + UniformRandomNumberGenerator&& g); |
| 526 | + |
515 | 527 | // \ref{alg.random.shuffle}, shuffle:
|
516 | 528 | template<class RandomAccessIterator, class UniformRandomNumberGenerator>
|
517 | 529 | void shuffle(RandomAccessIterator first,
|
|
2081 | 2093 | applications of the corresponding predicate.
|
2082 | 2094 | \end{itemdescr}
|
2083 | 2095 |
|
| 2096 | +\indexlibrary{\idxcode{search}}% |
| 2097 | +\begin{itemdecl} |
| 2098 | +template<class ForwardIterator, class Searcher> |
| 2099 | + ForwardIterator search(ForwardIterator first, ForwardIterator last, |
| 2100 | + const Searcher& searcher); |
| 2101 | +\end{itemdecl} |
| 2102 | + |
| 2103 | +\begin{itemdescr} |
| 2104 | +\pnum |
| 2105 | +\effects |
| 2106 | +Equivalent to \tcode{return searcher(first, last);} |
| 2107 | + |
| 2108 | +\pnum |
| 2109 | +\remarks |
| 2110 | +\tcode{Searcher} need not meet the \tcode{CopyConstructible} requirements. |
| 2111 | +\end{itemdescr} |
| 2112 | + |
| 2113 | + |
2084 | 2114 | \rSec1[alg.modifying.operations]{Mutating sequence operations}
|
2085 | 2115 |
|
2086 | 2116 | \rSec2[alg.copy]{Copy}
|
|
2930 | 2960 | assignments.
|
2931 | 2961 | \end{itemdescr}
|
2932 | 2962 |
|
| 2963 | +\rSec2[alg.random.sample]{Sample} |
| 2964 | + |
| 2965 | +\indexlibrary{\idxcode{sample}}% |
| 2966 | +\begin{itemdecl} |
| 2967 | +template<class PopulationIterator, class SampleIterator, |
| 2968 | + class Distance, class UniformRandomNumberGenerator> |
| 2969 | + SampleIterator sample(PopulationIterator first, PopulationIterator last, |
| 2970 | + SampleIterator out, Distance n, |
| 2971 | + UniformRandomNumberGenerator&& g); |
| 2972 | +\end{itemdecl} |
| 2973 | + |
| 2974 | +\begin{itemdescr} |
| 2975 | +\pnum |
| 2976 | +\requires |
| 2977 | +\begin{itemize} |
| 2978 | +\item |
| 2979 | +\tcode{PopulationIterator} shall meet the requirements of an \tcode{InputIterator} type. |
| 2980 | +\item |
| 2981 | +\tcode{SampleIterator} shall meet the requirements of an \tcode{OutputIterator} type. |
| 2982 | +\item |
| 2983 | +\tcode{SampleIterator} shall meet the additional requirements of a \tcode{RandomAccessIterator} type |
| 2984 | +unless \tcode{PopulationIterator} meets the additional requirements of a \tcode{ForwardIterator} type. |
| 2985 | +\item |
| 2986 | +\tcode{PopulationIterator}'s value type shall be writable to \tcode{out}. |
| 2987 | +\item |
| 2988 | +\tcode{Distance} shall be an integer type. |
| 2989 | +\item |
| 2990 | +\tcode{UniformRandomNumberGenerator} shall meet the requirements of a uniform random number generator type (\ref{rand.req.urng}) |
| 2991 | +whose return type is convertible to \tcode{Distance}. |
| 2992 | +\item |
| 2993 | +\tcode{out} shall not be in the range \range{first}{last}. |
| 2994 | +\end{itemize} |
| 2995 | + |
| 2996 | +\pnum |
| 2997 | +\effects |
| 2998 | +Copies \tcode{min(last - first, n)} elements (the \defn{sample}) |
| 2999 | +from \range{first}{last} (the \defn{population}) to \tcode{out} |
| 3000 | +such that each possible sample has equal probability of appearance. |
| 3001 | +\enternote |
| 3002 | +Algorithms that obtain such effects include \term{selection sampling} |
| 3003 | +and \term{reservoir sampling}. |
| 3004 | +\exitnote |
| 3005 | + |
| 3006 | +\pnum |
| 3007 | +\returns |
| 3008 | +The end of the resulting sample range. |
| 3009 | + |
| 3010 | +\pnum |
| 3011 | +\complexity |
| 3012 | +O(\tcode{last - first}). |
| 3013 | + |
| 3014 | +\pnum |
| 3015 | +\remarks |
| 3016 | +\begin{itemize} |
| 3017 | +\item |
| 3018 | +Stable if and only if \tcode{PopulationIterator} meets the |
| 3019 | +requirements of a \tcode{ForwardIterator} type. |
| 3020 | +\item |
| 3021 | +To the extent that the implementation of this function makes use of |
| 3022 | +random numbers, the object \tcode{g} shall serve as the |
| 3023 | +implementation's source of randomness. |
| 3024 | +\end{itemize} |
| 3025 | +\end{itemdescr} |
| 3026 | + |
2933 | 3027 | \rSec2[alg.random.shuffle]{Shuffle}
|
2934 | 3028 |
|
2935 | 3029 | \indexlibrary{\idxcode{shuffle}}%
|
2936 | 3030 | \begin{itemdecl}
|
2937 | 3031 | template<class RandomAccessIterator, class UniformRandomNumberGenerator>
|
2938 | 3032 | void shuffle(RandomAccessIterator first,
|
2939 |
| - RandomAccessIterator last, |
2940 |
| - UniformRandomNumberGenerator&& g); |
| 3033 | + RandomAccessIterator last, |
| 3034 | + UniformRandomNumberGenerator&& g); |
2941 | 3035 | \end{itemdecl}
|
2942 | 3036 |
|
2943 | 3037 | \begin{itemdescr}
|
|
0 commit comments