Crates.io | datrie |
lib.rs | datrie |
version | 1.0.0 |
source | src |
created_at | 2024-09-03 10:15:40.978162 |
updated_at | 2024-09-03 10:15:40.978162 |
description | Double array trie implementation of rust |
homepage | |
repository | https://github.com/biyuehu/datrie |
max_upload_size | |
id | 1361541 |
size | 45,323 |
Double array trie implementation of rust.
use datrie;
fn main() {
let mut dat = datrie::Dat::new();
dat.append("我", 1);
dat.append("我喜欢", 2);
dat.load(vec![("我喜欢你", 3), ("你不配", 4)]);
assert_eq!(
dat.search("我喜欢你"),
vec![
("我".to_string(), 1),
("我喜欢".to_string(), 2),
("我喜欢你".to_string(), 3)
]
);
assert_eq!(dat.search("配!"), vec![]);
assert_eq!(dat.lookup("我喜欢你"), Some(3));
assert_eq!(dat.lookup("我喜欢她"), None);
assert!(dat.contain("你不配"));
assert!(!dat.contain("你配"));
}