is_permutation

Determines whether the elements in a given range form a valid permutation. A permutation is a series of elements in which all of the elements that test true for a condition precede elements that return false.

template<class FwdIt1, class FwdIt2>
    bool is_permutation(FwdIt first1, FwdIt last1,
        FwdIt first2); 
template<class FwdIt1, class FwdIt2, class Pr>
    bool is_permutation(FwdIt first1, FwdIt last1,
        FwdIt first2, Pr pred);

Parameters

  • first1
    A forward iterator that refers to the first element of the given range.

  • last1
    A forward iterator that refers to the non-inclusive last element of the given range.

  • first2
    A forward iterator that refers to the first element of a second range, used for comparison.

  • pred
    A predicate that returns a bool.

Return Value

true when all of the elements in the given range that test true for a condition come before any elements that test false; otherwise, false.

Remarks

The first template function assumes that there are as many elements in the range beginning at first2 as there are in the range designated by [first1, last1). It returns true only if, for each element X in the range designated by [first1, last1) there are as many elements Y in the same range for which X == Y as there are in the range beginning at first2. Here, operator== must perform a pairwise comparison between its operands.

The second template function behaves the same, except that it replaces operator==(X, Y) with pred(X, Y).

Requirements

Header: <algorithm>

Namespace: std

See Also

Reference

<algorithm>

Standard Template Library