This library remains a constant companion. I've reworked my previous pull request significantly. I'll include my write up from the CHANGELOG that explains the changes as well as I'm able.
Use iterators for search results.
Benefits being that they're lazy, short-circuitable, and require less memory.
let a: Vec<Vec<u8>> = trie.predictive_search("ech").take(10).collect();
Allow Label collection type to be specified.
This includes machinery in crate::try_collect to allow us to collect into
String directly.
let a: Vec<Vec<u8>> = trie.predictive_search("ech").collect();
let b: Vec<String> = trie.predictive_search("ech").collect();
Add incremental search.
Let's the user build their query one label at a time.
If your search can be O(log n) instead of O(m log n), do that.
Add Trie::postfix_search()
Add map::Trie::exact_match_mut() to mutate map Values
Add Trie::longest_prefix()
Find the longest prefix. This is the kind of behavior one would want to implement tab completion for instance.
No longer panics on zero-length string queries.
Previously a zero-length query would instantiate the entirety of the trie
essentially uncompressed. Now, however, an iterator only allocates one word at
a time, and one can limit their search results to avoid whole trie collection.
let b: Vec<String> = trie.predictive_search("").take(100).collect();
Of these changes perhaps the postfix_search is superfluous and could be omitted. (It's used internally but maybe shouldn't be exposed.)
The biggest change is that searches from crate::Trie do not return a Vec but an iterator and is certainly a breaking change. However, I think the benefits are worth it.
Happy to hear your thoughts on the changes. Thanks again for this very useful library.
Oh, and this also makes Trie clone-able provided the other two PRs to louds-rs and fids-rs are accepted.
This library remains a constant companion. I've reworked my previous pull request significantly. I'll include my write up from the CHANGELOG that explains the changes as well as I'm able.
Use iterators for search results.
Benefits being that they're lazy, short-circuitable, and require less memory.
Allow
Label
collection type to be specified.This includes machinery in
crate::try_collect
to allow us to collect intoString
directly.Add incremental search.
Let's the user build their query one label at a time.
If your search can be O(log n) instead of O(m log n), do that.
Add
Trie::postfix_search()
Add
map::Trie::exact_match_mut()
to mutate mapValue
sAdd
Trie::longest_prefix()
Find the longest prefix. This is the kind of behavior one would want to implement tab completion for instance.
No longer panics on zero-length string queries.
Previously a zero-length query would instantiate the entirety of the trie essentially uncompressed. Now, however, an iterator only allocates one word at a time, and one can limit their search results to avoid whole trie collection.
Of these changes perhaps the postfix_search is superfluous and could be omitted. (It's used internally but maybe shouldn't be exposed.)
The biggest change is that searches from
crate::Trie
do not return aVec
but an iterator and is certainly a breaking change. However, I think the benefits are worth it.Happy to hear your thoughts on the changes. Thanks again for this very useful library.
Oh, and this also makes Trie clone-able provided the other two PRs to louds-rs and fids-rs are accepted.