[Issue 12752] New: std.algorithm.isPermutation

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri May 16 01:44:41 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12752

          Issue ID: 12752
           Summary: std.algorithm.isPermutation
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: bearophile_hugs at eml.cc

This C++ algorithm is useful in post-conditions and unittests to verify the
correctness of sorting, and in other situations:
http://www.cplusplus.com/reference/algorithm/is_permutation/

The Phobos algorithm could be named "isPermutation(x, y)", that returns a
boolean.

----------

A related algorithm could return an array of indexes that represent the mapping
from the first to the second array.

I am also thinking about a related range that could be named
"assumePermutationOf(x, y)" that returns a range like std.range.assumeSorted,
but it's not easy to use it well.

--


More information about the Digitalmars-d-bugs mailing list