Hi all,

I'm discovering the D language that seems very nice in many
aspects, but I'm quite confused by the container and range APIs
while trying to design a very simple interface-oriented API.

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

I'm trying to achieve something like that (approximate D code):

interface MyObjectSet
{
     void add(MyObject o);
     void SortedRange!MyObject opSlice();
}

class SomeRedBlackBasedImplementation
{
     private RedBlackTree!MyObject sequence = new
RedBlackTree!MyObject();

     void add(MyObject o) { this.sequence.insert(o); }
     void SortedRange!MyObject opSlice() { XXXX? }
}


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.

It seems to me that the Range used by RedBlackTree is a kind of
private struct that does not implement an interface but just
complies with some implicit contract about range properties. Am I
right ? If so how is it possible to make it fit in a more generic
framework ?

Thank you all for your help

Best regards,
Fred

Reply via email to