michaelsproul / rust_radix_trie

Fast generic radix trie implemented in Rust
https://docs.rs/radix_trie/
MIT License
188 stars 33 forks source link

Implement iterators .iter() .keys() .values() #1

Closed allan-simon closed 9 years ago

allan-simon commented 9 years ago

like it has been done in sequence trie

today i tried to implement them by adding a property "parent" (Option on a pointer of the parent trie node) to the TrieNode , so that the iterator would not need to keep a stack of the trie node he's traversing, but I didn't get it to compile (because of borrowed value being moved when setting the parent attribute )

Now that I think about it, the stack solution may not be that slower , and it will not need to add one more attribute for every single trienode.

michaelsproul commented 9 years ago

Yeah, because of the whole ownership thing, storing a link back to a parent node requires reference-counting/weak pointers or raw pointers (and unsafety).

allan-simon commented 9 years ago

awesome, i'm gonna update my code today to switch from sequence_trie to radix trie

michaelsproul commented 9 years ago

Let me know how that goes! :smile: