std::experimental::ranges::is_permutation
Defined in header <experimental/ranges/algorithm>
|
||
template< ForwardIterator I1, Sentinel<I1> S1, ForwardIterator I2, Sentinel<I2> S2, class Pred = ranges::equal_to<>, |
(1) | (ranges TS) |
template< ForwardRange R1, ForwardRange R2, class Pred = ranges::equal_to<>, class Proj1 = ranges::identity, class Proj2 = ranges::identity > |
(2) | (ranges TS) |
template< ForwardIterator I1, Sentinel<I1> S1, class I2, class Pred = ranges::equal_to<>, |
(3) | (ranges TS) (deprecated) |
template< ForwardRange R1, class I2, class Pred = ranges::equal_to<>, class Proj1 = ranges::identity, class Proj2 = ranges::identity > |
(4) | (ranges TS) (deprecated) |
[
first1,
last1)
that makes the range equal to [
first2,
last2)
, and false otherwise.Two ranges are considered equal if they have the same number of elements and, for every iterator i
in the range [
first1,
last1)
, ranges::invoke(pred, ranges::invoke(proj1, *i), ranges::invoke(proj2, *(first2 + (i - first1)))) is true.
Notwithstanding the declarations depicted above, the actual number and order of template parameters for algorithm declarations is unspecified. Thus, if explicit template arguments are used when calling an algorithm, the program is probably non-portable.
Parameters
first1, last1 | - | the first range of the elements |
r1 | - | the first range of the elements |
first2, last2 | - | the second range of the elements |
r2 | - | the second range of the elements |
first2_ | - | the beginning of the second range of the elements |
pred | - | predicate to apply to the projected elements |
proj1 | - | projection to apply to the elements in the first range |
proj2 | - | projection to apply to the elements in the second range |
Return value
true if the range [
first1,
last1)
is a permutation of the range [
first2,
last2)
.
Complexity
At most O(N2) applications of the predicate and each projection, or exactly N if the sequences are already equal, where N = last1 - first1.
However if SizedSentinel<S1, I1> && SizedSentinel<S2, I2> is satisfied and last1 - first1 != last2 - first2, no applications of the predicate and projections are made.
Example
This section is incomplete Reason: no example |
See also
(C++11) |
determines if a sequence is a permutation of another sequence (function template) |
generates the next greater lexicographic permutation of a range of elements (function template) | |
generates the next smaller lexicographic permutation of a range of elements (function template) |