Expand description
Rust implementation of Pruning Radix Trie, orignially by Wolf Garbe.
A Radix Trie or Patricia Trie is a space-optimized trie (prefix tree). A Pruning Radix trie is a novel Radix trie algorithm, that allows pruning of the Radix trie and early termination of the lookup.
The trie can only be appended to, terms cannot be removed nor payloads altered.
§Usage
use pruning_radix_trie::{PruningRadixTrie, Result};
let mut trie = PruningRadixTrie::new();
trie.add("heyo", vec![1, 2, 3], 5);
trie.add("hello", vec![3, 4, 5], 10);
trie.add("hej", vec![5, 6, 7], 20);
let results = trie.find("he", 10);
for Result { term, payload, weight } in results {
println!("{:10}{:?}{:>4}", term, payload, weight);
}
//hej [7, 8, 9] 20
//hello [4, 5, 6] 10
//heyo [1, 2, 3] 5
let results = trie.find_with_filter("he", 10, |p| p.contains(&3));
for Result { term, payload, weight } in results {
println!("{:10}{:?}{:>4}", term, payload, weight);
}
//hello [3, 4, 5] 10
//heyo [1, 2, 3] 5