trie_dart library
A generic Trie (prefix tree) for Dart.
Provides a Trie data structure that supports synonym-based path chaining and sequential keyword search. Define paths with TriePath, attach synonyms, and search concatenated keywords to collect matched data.
import 'package:trie_dart/trie_dart.dart';
var trie = Trie<String>.withInitialData(
List.of({
TriePath<String>.withData("ABC").addSynonym("abc"),
TriePath<String>.withData("ABCD").addSynonym("abcd"),
}),
);
var result = trie.search("abcabcd");
print(result.data); // [ABC, ABCD]
print(result.matched); // abcabcd
print(result.remaining); // (empty)
Classes
-
Trie<
T> - A generic Trie (prefix tree) that supports sequential keyword search with synonym-based path chaining.
-
TriePath<
T> - Represents a path entry in a Trie with optional data and synonyms.
-
TrieResult<
T> - The result of a Trie.search operation.