Bug 12752 – std.algorithm.isPermutation

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-05-16T08:44:00Z
Last change time
2015-10-04T18:21:00Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-05-16T08:44:41Z
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.
Comment #1 by jack — 2015-09-02T17:39:47Z
Comment #2 by github-bugzilla — 2015-09-17T20:29:48Z
Comment #3 by bearophile_hugs — 2015-09-18T08:44:56Z
(In reply to github-bugzilla from comment #2) > Commits pushed to master at https://github.com/D-Programming-Language/phobos Lot of work for one algorithm. The range returned by assumePermutationOf(x, y) is sometimes usueful.
Comment #4 by github-bugzilla — 2015-10-04T18:21:00Z