cpp/algorithm/is permutation

Returns if there exists a  of the elements in the range  that makes that range equal to the range, where  denotes  if it was not given.

@1,3@ Elements are compared using. The behavior is undefined if it is not an. @2,4@ Elements are compared using the given binary predicate. The behavior is undefined if it is not an equivalence relation.

Return value
if the range is a permutation of the range.

Complexity
At most applications of the predicate, or exactly  if the sequences are already equal, where  is.

However if and  meet the requirements of  and  no applications of the predicate are made.

Note
The can be used in testing, namely to check the correctness of rearranging algorithms (e.g. sorting, shuffling, partitioning). If is an original range and  is a permuted range then  means that  consist of "the same" elements, maybe staying at other positions.