tango iterators and related questions

Steven Schveighoffer schveiguy at yahoo.com
Tue Apr 21 06:25:30 PDT 2009


On Tue, 21 Apr 2009 08:46:18 -0400, MLT <none at anon.com> wrote:

> D is really great. I am trying to implement a medium sized project to  
> get to know it.
> For this I need a sorted data structure, with cheap search, and somewhat  
> cheap forward and backward traversing.
>
> I thought I should use tango (though it is a bit confusing that there is  
> so much overlap between tango and phobos...)
> I wanted to use SortedMap. However, I can not figure out how to use the  
> Iterators of SortedMap.
>
> When I place the Iterator somewhere, how do I find the element  
> (key+value) where it's at?
> I see how to get the next key and value (using i.next(k,v)), but I can  
> not see how to get the current one, and how to go up and down the keys.  
> I need to find a certain place, and then look at the key & value above  
> and below that location....
>
> I saw that dcollections does provide this ability, with its cursor.
>
> So new I'm wondering if to use tango+dcollections, phobos+dcollections,  
> or just pick and choose.
>
> I would also really like to stay as standard as possible.
>
> What do you usually use?

dcollections+tango should do the trick for you.  It is incidentally what I  
use (of course I wrote dcollections, so big surprise there ;)

You can submit an enhancement request to Tango to see if there is interest  
in adding bi-directional iterator functionality to the SortedMap.  I know  
there is some bidirectional support in e.g. circular lists.

-Steve


More information about the Digitalmars-d-learn mailing list