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 trie_rs::map::{Trie, TrieBuilder}. #20

Closed shanecelis closed 6 months ago

shanecelis commented 6 months ago

Thank you for making this project and making it available. I added a key-value trie in the map module. I have seen others add this functionality with a whole sale reimplementation. This patch differs in that it doesn't change the original code; it really only adds a facade on top of the existing trie implementation in a separate module. It uses a private struct KeyValue<K,V>(K, V) pair where only the key is used for Eq and Ord.

In addition, I added a is_prefix() function. It's merely to avoid an allocation when all one wants is to know whether the given query is a prefix.

I added some docs to the public functions.

I did not bump any version numbers.

laysakura commented 6 months ago

Thanks! Released in v0.2.0: https://crates.io/crates/trie-rs

shanecelis commented 6 months ago

Thank you kindly for this very fast turnaround!