ab-radix-trie

Crates.ioab-radix-trie
lib.rsab-radix-trie
version0.2.1
sourcesrc
created_at2023-12-25 12:23:26.286172
updated_at2024-03-27 13:42:47.265369
descriptionA compressed radix trie implementation supporting matching rules
homepagehttps://github.com/avnerbarr/radix-trie
repositoryhttps://github.com/avnerbarr/radix-trie
max_upload_size
id1080207
size56,477
Avner (avnerbarr)

documentation

https://docs.rs/ab-radix-trie/latest/ab_radix_trie/

README

Latest Version

Radix-Trie

Radix-trie implementation i.e. compressed prefix-trie

https://en.wikipedia.org/wiki/Radix_tree

Some nice features:

  1. Compressed nodes
  2. Fuzzy matching - match on whitespace, replacing characters, etc.
  3. Supports all unicode characters
  4. Arbitrarily associate values to text (i.e. map strings to values)
  5. Serializable with serde

Performance

Approximately:

  1. insertion O(depth of trie)

  2. retrieval O(depth of trie)

  3. deletion O(depth of trie)

  4. Space - I don't know really, but it will behave according to ~O(entropy of text) - Similar texts are compressed together - i.e. "ABC", "ABCD" will occupy O("ABCD") space split into "ABC" and "D"

Usage:

I suggest checking out the examples and the tests for some patterns

The basic usage is along these lines

let mut trie: Trie<i32> = Trie::new();
trie.insert("romanus", None);
trie.insert("romulus", Some(10));
trie.insert("rubens", None);
trie.insert("ruber", None);
trie.insert("rubicon", None);
trie.insert("rubicundus", None);
Commit count: 15

cargo fmt