tango iterators and related questions
Steven Schveighoffer
schveiguy at yahoo.com
Tue Apr 21 08:54:01 PDT 2009
On Tue, 21 Apr 2009 10:08:03 -0400, MLT <none at anon.com> wrote:
> Steven Schveighoffer Wrote:
>
>> On Tue, 21 Apr 2009 08:46:18 -0400, MLT <none at anon.com> wrote:
>
>> dcollections+tango should do the trick for you. It is incidentally
>> what I
>> use (of course I wrote dcollections, so big surprise there ;)
>>
>
> Good! I just managed to compile my first program using 0.02
> BTW: the svn version gave me errors like:
> /usr/local/include/d/dcollections/TreeMap.d(96): Error: undefined
> identifier DefaultCompare
> Maybe it has something to do with D2? I'm not sure.
> 0.02 worked, except that I had to manually ranlib the resulting library.
>
No, I was in the middle of reorganizing the interface hierarchy (among
other things) when I discovered a blocker bug:
http://d.puremagic.com/issues/show_bug.cgi?id=2061
I stopped working on it in hopes the bug would be fixed, but it hasn't
been :( If you are a member of digitalmars's bug tracker, vote for the
issue, maybe it will get more attention!
>> 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.
>>
>
> Yes. But the problem isn't so much the bi-directionality, and more just
> accessing where I currently am. Though of course with bi-directional
> iterators, I could go next, then prev, and see what I have where I am.
> Because next and prev are O(logN) this isn't SO cheap though.
Tango iterators tie the "move next" and "get" operations together, similar
to Java's. I don't know how open Kris would be to changing that, but you
can always submit an enhancement request to see if it is accepted. That
would be my recommendation.
And O(logN) is very very cheap ;) Especially to be able to have a sorted
dictionary. If you don't need O(logN) insertion and deletion (i.e. if you
are not going to continually update the dictionary), you could consider
having a sorted array (binary search for lookup).
-Steve
More information about the Digitalmars-d-learn
mailing list