pfx

Crates.iopfx
lib.rspfx
version0.4.1
sourcesrc
created_at2024-04-02 18:24:47.736746
updated_at2024-04-07 08:21:51.713187
descriptionA prefix tree (map and set), implemented without any unsafe
homepage
repositoryhttps://github.com/H2CO3/pfx
max_upload_size
id1193976
size61,522
Árpád Goretity  (H2CO3)

documentation

https://docs.rs/pfx

README

# PFX: A 100% safe, blob-oriented prefix tree This crate provides a prefix tree map and set data structure, implemented purely in safe Rust. The API is very similar to `std::collections::{HashMap, BTreeMap}`, including iteration and an entry API. Iteration proceeds in lexicographical order as determined by the keys. A notable addition is Prefix search, allowing iteration over all entries whose key starts with a specified prefix. ## Example ```rust use pfx::PrefixTreeMap; fn main() { let mut map: PrefixTreeMap = PrefixTreeMap::new(); map.insert("abc".into(), 123); map.insert("def".into(), 456); map.insert("defghi".into(), 789); assert_eq!(map.get("abc").copied(), Some(123)); assert_eq!(map.get("abcdef").copied(), None); assert_eq!(map.get("ab").copied(), None); for (key, value) in map.prefix_iter("de") { println!("{key} => {value}"); } } ```
Commit count: 6

cargo fmt