| Crates.io | trie-alg |
| lib.rs | trie-alg |
| version | 0.4.0 |
| created_at | 2024-12-22 07:10:39.940435+00 |
| updated_at | 2024-12-26 14:14:29.803023+00 |
| description | Trie implementation |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1491740 |
| size | 1,486,034 |
trie-algImplement a trie space optimized for character set in use
let mut t = trie!();
t.add("abc"); // true
t.add("abc"); // false
t.contains("abc"); // true
t.contains("a"); // false
let mut t = multi_trie!();
t.add("abc"); // true
t.count("abc") // 1
t.add("abc"); // false
t.count("abc") // 2
t.contains("abc") // true
t.contains("a") // false
t.count("a") // 0
struct LowerCaseWithHash();
impl CharSet for LowerCaseWithHash {
const SIZE: usize = 27;
fn map(ch: char) -> usize {
if ch.is_ascii_lowercase() {
ch as usize - 'a' as usize
} else {
26
}
}
fn unmap(hash: usize) -> char {
if hash < 26 {
(b'a'+hash as u8) as char
}else {
'#'
}
}
}
let mut t = multi_trie!(LowerCaseWithHash);