Mike Hammond > data-trie-0.01 > Data::Trie

Download:
data-trie-0.01.tar.gz

Dependencies

Annotate this POD

Related Modules

Devel::Size
Tree::Trie
Inline::C
more...
By perlmonks.org

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Data::Trie - An implementation of a letter trie

SYNOPSIS ^

        use Data::Trie;
        $t = Data::Trie->new;
        $t->add('orange', 'kind of fruit');
        ($result, $data) = $t->lookup->('orange');
        $t->remove('orange');
        $t->getAll;

DESCRIPTION ^

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.

COMPARE ^

This implementation differs from Tree::Trie in that lookup() checks for a match, rather than checking for whether the current string is a prefix.

VERSION ^

0.01

AUTHOR ^

Michael Hammond, hammond@u.arizona.edu

syntax highlighting: