an optional parameter to change how equality is defined
A finite input range
A finite random access range
An index into r2 such that r2 permuted by index is a prefix of r1.
true if all of the elements in r1 appear the same number of times in r2. Otherwise, returns false.
enum r1 = [1, 2, 3, 4, 5, 6]; enum r2 = [1, 3, 2, 4, 5, 6]; assert(isPermutation(r1, r2)); auto index = new size_t[r2.length]; assert(isPermutation(r1, r2, index)); assert(index == [0, 2, 1, 3, 4, 5]);
Checks if both ranges are permutations of each other.
pred must be an equivalence relation, e.i. for all inputs:
// reflexive pred(a, a) == true // symmetric pred(a, b) == pred(b, a) // transitive !(pred(a, b) && pred(b, c)) || pred(a, c)