Skip to content

Commit

Permalink
[algorithms] Move non-modifying algorithms away
Browse files Browse the repository at this point in the history
from [alg.modifying.operations].

For is_partitioned, create a new subsection [alg.is_partitioned]
under [alg.nonmodifying].
For partition_point, create a new subsection [partition.point]
under [alg.binary.search].

Fixes #289.
  • Loading branch information
jensmaurer committed Dec 14, 2016
1 parent c39761a commit 9507827
Showing 1 changed file with 56 additions and 52 deletions.
108 changes: 56 additions & 52 deletions source/algorithms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@
InputIterator2 first2, InputIterator2 last2,
BinaryPredicate pred);

template <class InputIterator, class Predicate>
bool is_partitioned(InputIterator first, InputIterator last, Predicate pred);
template <class ExecutionPolicy, class InputIterator, class Predicate>
bool is_partitioned(ExecutionPolicy&& exec, // see \ref{algorithms.parallel.overloads}
InputIterator first, InputIterator last, Predicate pred);

template<class ForwardIterator1, class ForwardIterator2>
bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2);
Expand Down Expand Up @@ -531,12 +537,6 @@
UniformRandomBitGenerator&& g);

// \ref{alg.partitions}, partitions
template <class InputIterator, class Predicate>
bool is_partitioned(InputIterator first, InputIterator last, Predicate pred);
template <class ExecutionPolicy, class InputIterator, class Predicate>
bool is_partitioned(ExecutionPolicy&& exec, // see \ref{algorithms.parallel.overloads}
InputIterator first, InputIterator last, Predicate pred);

template<class ForwardIterator, class Predicate>
ForwardIterator partition(ForwardIterator first,
ForwardIterator last,
Expand Down Expand Up @@ -568,10 +568,6 @@
InputIterator first, InputIterator last,
OutputIterator1 out_true, OutputIterator2 out_false,
Predicate pred);
template<class ForwardIterator, class Predicate>
ForwardIterator partition_point(ForwardIterator first,
ForwardIterator last,
Predicate pred);

// \ref{alg.sorting}, sorting and related operations
// \ref{alg.sort}, sorting
Expand Down Expand Up @@ -714,6 +710,11 @@
bool binary_search(ForwardIterator first, ForwardIterator last,
const T& value, Compare comp);

template<class ForwardIterator, class Predicate>
ForwardIterator partition_point(ForwardIterator first,
ForwardIterator last,
Predicate pred);

// \ref{alg.merge}, merge
template<class InputIterator1, class InputIterator2, class OutputIterator>
OutputIterator merge(InputIterator1 first1, InputIterator1 last1,
Expand Down Expand Up @@ -2038,6 +2039,30 @@
applications of the corresponding predicate.
\end{itemdescr}

\rSec2[alg.is_partitioned]{Is partitioned}

\indexlibrary{\idxcode{is_partitioned}}%
\begin{itemdecl}
template <class InputIterator, class Predicate>
bool is_partitioned(InputIterator first, InputIterator last, Predicate pred);
template <class ExecutionPolicy, class InputIterator, class Predicate>
bool is_partitioned(ExecutionPolicy&& exec,
InputIterator first, InputIterator last, Predicate pred);
\end{itemdecl}

\begin{itemdescr}
\pnum
\requires \tcode{InputIterator}'s value type shall be convertible to \tcode{Predicate}'s argument type.

\pnum
\returns \tcode{true} if
\range{first}{last} is empty or if
\range{first}{last} is partitioned by \tcode{pred}, i.e. if all elements that satisfy \tcode{pred} appear before those that do not.

\pnum
\complexity Linear. At most \tcode{last - first} applications of \tcode{pred}.
\end{itemdescr}

\rSec2[alg.is_permutation]{Is permutation}

\indexlibrary{\idxcode{is_permutation}}%
Expand Down Expand Up @@ -3339,28 +3364,6 @@

\rSec2[alg.partitions]{Partitions}

\indexlibrary{\idxcode{is_partitioned}}%
\begin{itemdecl}
template <class InputIterator, class Predicate>
bool is_partitioned(InputIterator first, InputIterator last, Predicate pred);
template <class ExecutionPolicy, class InputIterator, class Predicate>
bool is_partitioned(ExecutionPolicy&& exec,
InputIterator first, InputIterator last, Predicate pred);
\end{itemdecl}

\begin{itemdescr}
\pnum
\requires \tcode{InputIterator}'s value type shall be convertible to \tcode{Predicate}'s argument type.

\pnum
\returns \tcode{true} if
\range{first}{last} is empty or if
\range{first}{last} is partitioned by \tcode{pred}, i.e. if all elements that satisfy \tcode{pred} appear before those that do not.

\pnum
\complexity Linear. At most \tcode{last - first} applications of \tcode{pred}.
\end{itemdescr}

\indexlibrary{\idxcode{partition}}%
\begin{itemdecl}
template<class ForwardIterator, class Predicate>
Expand Down Expand Up @@ -3481,26 +3484,6 @@
\complexity Exactly \tcode{last - first} applications of \tcode{pred}.
\end{itemdescr}

\indexlibrary{\idxcode{partition_point}}%
\begin{itemdecl}
template<class ForwardIterator, class Predicate>
ForwardIterator partition_point(ForwardIterator first,
ForwardIterator last,
Predicate pred);
\end{itemdecl}


\begin{itemdescr}
\pnum
\requires \tcode{ForwardIterator}'s value type shall be convertible to \tcode{Predicate}'s argument type. \range{first}{last} shall be partitioned by \tcode{pred}, i.e. all elements that satisfy \tcode{pred} shall appear before those that do not.

\pnum
\returns An iterator \tcode{mid} such that \tcode{all_of(first, mid, pred)} and \tcode{none_of(mid, last, pred)} are both \tcode{true}.

\pnum
\complexity \bigoh{\log(\tcode{last - first})} applications of \tcode{pred}.
\end{itemdescr}


\rSec1[alg.sorting]{Sorting and related operations}

Expand Down Expand Up @@ -4199,6 +4182,27 @@
comparisons.
\end{itemdescr}

\rSec3[partition.point]{\tcode{partition_point}}

\indexlibrary{\idxcode{partition_point}}%
\begin{itemdecl}
template<class ForwardIterator, class Predicate>
ForwardIterator partition_point(ForwardIterator first,
ForwardIterator last,
Predicate pred);
\end{itemdecl}

\begin{itemdescr}
\pnum
\requires \tcode{ForwardIterator}'s value type shall be convertible to \tcode{Predicate}'s argument type. \range{first}{last} shall be partitioned by \tcode{pred}, i.e. all elements that satisfy \tcode{pred} shall appear before those that do not.

\pnum
\returns An iterator \tcode{mid} such that \tcode{all_of(first, mid, pred)} and \tcode{none_of(mid, last, pred)} are both \tcode{true}.

\pnum
\complexity \bigoh{\log(\tcode{last - first})} applications of \tcode{pred}.
\end{itemdescr}

\rSec2[alg.merge]{Merge}

\indexlibrary{\idxcode{merge}}%
Expand Down

0 comments on commit 9507827

Please sign in to comment.