[Issue 10777] std.algorithm.multiSort to return a std.range.SortedRange

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Aug 5 15:42:36 PDT 2014


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

SzMK <szymon.kielbasa+dlang at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |szymon.kielbasa+dlang at gmail
                   |                            |.com

--- Comment #1 from SzMK <szymon.kielbasa+dlang at gmail.com> ---
I often use multiSort in bioinformatics applications.
To make multiSort more usable I (hopefully carefully) extended the range.d and
algorithm.d code (of 2.065) to add the following functionality:

- SortedRange has been extended to support one or more predicates; it
internally constructs the full predicate function out of separately provided
ones

- multiSort has been converted to return the modified SortedRange object

- assumeSorted has been modified to handle multiple predicates

The existing unittests do compile without any modifications; a few new ones
have been added.

The above changes are mostly of cosmetics nature.
But my primary motivation was to provide possibility to perform binary searches
with equalRange family of functions based not only on all predicates, but also
on a subset of leading ones (an example: a range of persons, sorted first by
surnames and then by given names should provide possibility to find a range of
persons with requested (surname and given name) as well as a range of persons
with requested surname). To achieve that I added:

- SortedRange.keepPreds!( numPreds ) function which returns the same range
annotated as SortedRange with possibly a smaller number of predicates.

--


More information about the Digitalmars-d-bugs mailing list