21 stable releases
new 3.0.4 | May 11, 2025 |
---|---|
3.0.3 | Mar 25, 2025 |
2.3.3 | Mar 9, 2025 |
1.1.1 | Jan 19, 2025 |
1.0.2 | Jul 22, 2024 |
#371 in Data structures
1,699 downloads per month
62KB
1.5K
SLoC
Dynamic trie in contrast to classic trie does not have fixed size alphabet associated with node.
Each node has dynamic alphabet of size as to satisfy exactly associated branches.
Dynamic Trie
Dynamic trie is trie that allows mapping of any T to any char iterator with asymptotical computational complexity based on that of std::collections::HashMap
.
Node occurs for each char
as defined by Rust language.
let mut trie = Trie::<char>::new();
let some = "información meteorológica".chars();
trie.ins('🌩', some.clone());
let one_more = "alimentación RSS".chars();
trie.ins('😋', one_more.clone());
assert_eq!(RemRes::Ok('😋'), trie.rem(one_more.clone()));
assert_eq!(AcqRes::Err(KeyErr::Unknown), trie.acq(one_more.clone()));
let mut res = trie.acq_mut(some.clone());
assert_eq!(AcqMutRes::Ok(&mut '🌩'), res);
let entry = res.uproot();
*entry = '🌞';
assert_eq!(AcqRes::Ok(&'🌞'), trie.acq(some.clone()));