pytries / hat-trie

HAT-Trie for Python
MIT License
86 stars 21 forks source link

Add keys_with_prefix and iterkeys_with_prefix methods #4

Open yflau opened 11 years ago

yflau commented 11 years ago

I noticed that luikore/hat-trie version adds some methods like hattrie_iter_with_prefix based on dcjones/hat-trie version, so I replace the dcjones/hat-trie with luikore/hat-trie version, and add keys_with_prefix and iterkeys_with_prefix methods based on hattrie_iter_with_prefix. I dont know if want to have such a change? if not, please ignore it.

kmike commented 11 years ago

Hmm, I don't know. I don't like the callback-based API introduced in luikore's fork - iterator-based API would have been much better. IMHO in long run it will have to be replaced because it is not flexible enough. So it looks like a stopgap solution.

I think that for now I'd leave this PR open without merging it. Let purity beat practicality :) People who need those features could use your fork.

Regarding the wrapper: instead of '(iter)key_with_prefix' methods I'd just provide 'prefix' argument to 'keys' and 'iterkeys', just like it was done in PyTrie, datrie, marisa-trie and DAWG.

yflau commented 11 years ago

Actually, I want to add 'prefix' argument reference to PyTrie and others at first, but for clarity and be consistent with hattrie_iter_with_prefix, I add the xxx_with_prefix methods, and I will modify it later :)

canadaduane commented 10 years ago

Just bumped in to this issue while trying to use the latest hat-trie in triez. It would be great if we could fix this up and merge in.