trie_dart 0.1.3 copy "trie_dart: ^0.1.3" to clipboard
trie_dart: ^0.1.3 copied to clipboard

Segmented Trie Core — A generic segmented Trie (prefix tree) for Dart with synonym-based path chaining and sequential keyword search.

example/trie_dart_example.dart

import 'package:trie_dart/trie_dart.dart';

void main() {
  var trie = Trie<String>.withInitialData(
    List.of({
      TriePath<String>.withData("ABC").addSynonym("abc"),
      TriePath<String>.withData("ABCD").addSynonym("abcd"),
    }),
  );

  // Full match — entire input is consumed
  var result = trie.search("abcabcd");
  print(result.data);        // [ABC, ABCD]
  print(result.matched);     // abcabcd
  print(result.remaining);   // (empty)
  print(result.isFullMatch); // true

  // Partial match — "xyz" is not in the trie
  var partial = trie.search("abcxyz");
  print(partial.data);        // [ABC]
  print(partial.matched);     // abc
  print(partial.remaining);   // xyz
  print(partial.isFullMatch); // false

  // No match
  var noMatch = trie.search("zzz");
  print(noMatch.data);      // []
  print(noMatch.hasData);   // false
  print(noMatch.remaining); // zzz
}
1
likes
160
points
8
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Segmented Trie Core — A generic segmented Trie (prefix tree) for Dart with synonym-based path chaining and sequential keyword search.

Repository (GitHub)
View/report issues

Topics

#trie #data-structure #search #prefix-tree #text-search

License

Apache-2.0 (license)

More

Packages that depend on trie_dart