dcollections 1.0 and 2.0a beta released
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon May 24 10:36:01 PDT 2010
On 05/24/2010 12:11 PM, bearophile wrote:
> Steven Schveighoffer:
>> Is it unreasonable to expect to be able
>> to iterate the keys in a trie? (I don't really know, I've never worked
>> with them)
>
> On tries you can iterate on all keys or on a sorted range of the keys.
There's one more way of iteration that's unique to tries - by key
element (e.g. if key is string, you iterate by character). That would be
an exploratory iteration.
At each step in the iteration you pass a character, so popFront() takes
an argument, it's popFront(char). trie.popFront('a') takes you to all
elements in the trie that start with 'a'. Then you can continue
exploring by e.g. trie.popFront('x') which takes you to all elements
that start with "ax". At any point the range may become dry (nothing
with this prefix). If the range is not empty, front() gives you
information about all strings that share the particular prefix you have
spanned (count and breadth comes to mind).
Andrei
More information about the Digitalmars-d-announce
mailing list