Ranges & containers : is it possible to get a SortedRange from a RedBlackTree ?

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 7 06:09:28 PDT 2014


Frédérik:

> Especially I can't figure out how std.containers can connect
> properly with std.ranges :

std.containers is still primitive, it needs to be improved and 
fleshed out, after Andrei's memory allocators.


> I would need to get the range that comes from the red black tree
> (as returned by this.sequence[]) but I can't figure out how to
> map it to a generic interface like SortedRange that would be
> suitable to write a clean interface above.

In Phobos there are very few true interfaces. Most "interfaces" 
are instead compile-time protocols for templates, that create 
different types. But in std.range there are also (rarely used) 
class-based range adaptors to do what you want.

Regarding RedBlackTree not already returning SortedRange, I think 
this could be fixed.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list