[Issue 20798] generic binarySearch (and others) should be available in std.algorithm

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 5 23:17:33 UTC 2020


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

ZombineDev <petar.p.kirov at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |petar.p.kirov at gmail.com

--- Comment #1 from ZombineDev <petar.p.kirov at gmail.com> ---
The following works:

struct S
{
    string s;
    int field;
}

void main()
{
    import std;

    auto someArr = 100.iota
        .map!(i => S("asd", i))
        .array
        .randomShuffle;

    someArr.sort!((a, b) => a.field < b.field);

    someArr
        .map!(x => x.field)
        .assumeSorted!((a, b) => a < b)
        .equalRange(42)
        .writeln;
}

So where does this approach fall short? Performance, convenience, and
accessibility?

--


More information about the Digitalmars-d-bugs mailing list