Data::Trie - An implementation of a letter trie
use Data::Trie; $t = Data::Trie->new; $t->add('orange', 'kind of fruit'); ($result, $data) = $t->lookup->('orange'); $t->remove('orange'); $t->getAll;
This module implements a letter trie data structure. This is a linked set of nodes representing a set of words. Starting from the root, each letter of an included word is a daughter node of the trie. Hence, if a word is in the trie, there will be a path from root to leaf for that word. If a word is not in the trie, there will be no such path.
This structure allows for a relatively compact representation of a set of words. This particular implementation allows each word to be stored alone or with some associated data item.
Note that the
remove() method does not prune nodes and thus a
Trie can only grow in size.
This implementation differs from Tree::Trie in that
lookup() checks for a match, rather than checking for whether the current string is a prefix.
Michael Hammond, email@example.com