basic_trie 1.5.2 copy "basic_trie: ^1.5.2" to clipboard
basic_trie: ^1.5.2 copied to clipboard

A simple trie implementation in Dart.

basic_trie #

pub package Build Status

A simple trie implementation in Dart.

Usage #

void main() {
  var trie = BasicTrie<int, String>();

  trie.set([1, 2, 3], '123');
  trie.set([1, 3, 5, 7], '1357');

  // Full match.
  print(trie.get([1, 2, 3]));
  // Node{value: 123, map: {}}

  // No match.
  print(trie.get([1, 4]));
  // null

  // Partial match (key path is valid but doesn't have a value associated with it)
  print(trie.get([1, 2]));
  // Node{value: null, map: {3: Node{value: 123, map: {}}}}

  // Delete a value.
  trie.remove([1, 2, 3]);
  print(trie.get([1, 2, 3]));
  // null

  // Renames the last key component of a value.
  trie.renameLastComponent([1, 3, 5, 7], -7);
  print(trie.get([1, 3, 5, 7]));
  // null
  print(trie.get([1, 3, 5, -7]));
  // Node{value: 1357, map: {}}
}
0
likes
150
points
36
downloads

Publisher

verified publisherflutter-cavalry.com

Weekly Downloads

A simple trie implementation in Dart.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on basic_trie