nWayUnion(tuple)?

bearophile bearophileHUGS at lycos.com
Wed Feb 27 11:36:43 PST 2013


Currently std.algorithm.nWayUnion requires an array of ranges, 
because it internally keeps them in a heap, to be fast when you 
give it hundreds+ of ranges.

But in some cases I'd like to merge different types of ranges, 
that I can't put in an array. Is this use case worth supporting 
(usually the number of ranges is small so for such use cases a 
heap is not so needed)?


import std.algorithm: nWayUnion, map;
import std.range: iota;
import std.typecons: tuple;
void main() {
     auto a = iota(10);
     auto b = [3, 6, 9];
     auto c = iota(11).map!q{a * a};
     auto r = nWayUnion(tuple(a, b, c));
}


(Or maybe I am missing something, and this is already possible in 
Phobos. This happened some times in past because it's not easy to 
fully understand the high flexibility of std.algorithm).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list