laysakura / trie-rs

Memory efficient trie (prefix tree) library based on LOUDS
https://crates.io/crates/trie-rs
Apache License 2.0
90 stars 10 forks source link

Add Key Value support #17

Closed sudarshan-reddy closed 4 months ago

sudarshan-reddy commented 1 year ago

This allows a user of this library to tie a value with the keys set for prefix Trie. The advantage of this is that a caller can call common_prefix_search_with_values to get all the prefix matches along with their values.

Note: This makes a breaking change to builder.push() to accept a K, and a V. I chose to go this way to keep the api simple. Happy to use a different push_with_val() method if that helps.

shanecelis commented 4 months ago

Thank you for your time and submitting this pull request. I had similar aspirations and needs. I submitted a PR that used the original Trie code and KeyValue<K,V> as a Label which was published as v0.2.0. It, however, had some issues and I ended up reworking the code to have map::Trie be the principal trie and crate::Trie essentially be a map::Trie<Label, ()>. The good news is this feature is available now in v0.3.0. The bad news is this PR will not be merged.