4 releases (breaking)
0.4.0 | Dec 26, 2024 |
---|---|
0.3.0 | Dec 25, 2024 |
0.2.0 | Dec 25, 2024 |
0.1.0 | Dec 22, 2024 |
#1824 in Data structures
375 downloads per month
1MB
418 lines
Contains (WOFF font, 400KB) NanumBarunGothic-0f09457c7a19b7c6.ttf.woff2, (WOFF font, 135KB) FiraSans-Medium-8f9a781e4970d388.woff2, (WOFF font, 130KB) FiraSans-Regular-018c141bf0843ffd.woff2, (WOFF font, 82KB) SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2, (WOFF font, 77KB) SourceSerif4-Regular-46f98efaafac5295.ttf.woff2, (WOFF font, 45KB) SourceCodePro-It-1cc31594bf4f1f79.ttf.woff2 and 3 more.
trie-alg
Implement 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);
lib.rs
:
trie-alg
Implement 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);
Todo
- Implement error handling for
CharSet
trait - Implement iterators to iterate over trie
- Implement
delete
method to remove string from trie - Implement
TrieMap
to store information at the trie node -> MultiTrie will derive from this - Implement function to count string with given prefix in the trie