[Issue 8405] Create overload for joiner which is random access for random access ranges

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Nov 9 14:29:28 PST 2014


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

bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs at eml.cc

--- Comment #2 from bearophile_hugs at eml.cc ---
Some use cases. Given a 2D array, I'd like to sort or shuffle its items seen as
sequential:


import std.stdio: writeln;
import std.algorithm: sort;
import std.range: joiner, chain;
import std.random: randomShuffle;
void sortAll(int[][] m) {
    m.joiner.sort(); // error
}
void shuffleAll(int[][] m) {
    m.joiner.randomShuffle; // error
}
void main() {
    auto m = [[10, 2], [30, 4]];
    m.writeln;
    chain(m[0], m[1]).sort(); // OK
    m.sortAll;
    m.writeln;
    m.shuffleAll;
    m.writeln;
}


Is it possible and reasonable for "joiner" to return a random access range in
such cases (where the input is a random access range of random access ranges,
this isn't an uncommon use case because built-in arrays are very common in D
code)?

--


More information about the Digitalmars-d-bugs mailing list