lr_trie

Crates.iolr_trie
lib.rslr_trie
version4.0.3
created_at2024-07-21 21:49:37.211681+00
updated_at2025-07-13 19:54:02.694925+00
descriptionLeft-Right trie is trie capable of mapping any string to any string.
homepage
repositoryhttps://github.com/deep-outcome/tries/tree/main/lr_trie
max_upload_size
id1310602
size72,863
mr-deepest-outcome (deep-outcome)

documentation

https://docs.rs/lr_trie/latest/lr_trie/index.html

README

Left-Right Trie

Left-Right trie is trie that allows mapping of any string to any string with complexity based on alphabet used size.

const ONE: &str = "emoción";
const ANOTHER: &str = "emotion";
const REPLACEMENT: &str = "equilibrio sicofísico";

let mut trie = LrTrie::new();

let one = &KeyEntry::new(ONE).unwrap();
let another = &KeyEntry::new(ANOTHER).unwrap();
let replacement = &KeyEntry::new(REPLACEMENT).unwrap();

trie.insert(one, another);
assert!(trie.member(one, LeftRight::Left).is_some());
assert!(trie.member(another, LeftRight::Left).is_none());
assert!(trie.member(another, LeftRight::Right).is_some());

trie.insert(one, replacement);
assert_eq!(
    Some(String::from(REPLACEMENT)),
    trie.member(&one, LeftRight::Left)
);
assert!(trie.member(another, LeftRight::Right).is_none());
assert_eq!(
    Some(String::from(ONE)),
    trie.member(replacement, LeftRight::Right)
);

assert_eq!(Ok(()), trie.delete(one, LeftRight::Left));

assert!(trie.member(one, LeftRight::Left).is_none());
assert!(trie.member(replacement, LeftRight::Right).is_none());

assert_eq!(Err(()), trie.delete(replacement, LeftRight::Right));
Commit count: 181

cargo fmt