Tree::Numbered 2.02 review
DownloadTree::Numbered is a thin N-ary tree structure with a unique number for each item. SYNOPSYS use Tree::Numbered; my $tree = Tr
|
|
Tree::Numbered is a thin N-ary tree structure with a unique number for each item.
SYNOPSYS
use Tree::Numbered;
my $tree = Tree::Numbered->new('John Doe');
$tree->append('John Doe Jr.');
$tree->append('Marry-Jane Doe');
while (my $branch = $tree->nextNode) {
$branch->delete if ($branch->getValue eq 'Stuff I dont want');
}
my $itemId = what_the_DB_says;
print join ' --- ', $tree->follow($itemId); # a list of items up to itemId.
$tree->allProcess( sub {
my $self = shift;
$self->getValue =~ /^(S*)/;
$self->addField('FirstName', $1);
} );
etc.
Tree::Numbered is a special N-ary tree with a number for each node. This is useful on many occasions. The first use I found for that (and wrote this for) was to store information about the selected item as a number instead of storing the whole value which is space-expensive.
Every tree also has a lucky number of his own that distinguishes it from other trees created by the same module. This module is thin on purpose and is meant to be a base class for stuff that can make use of this behaveiour. For example, I wrote Tree::Numbered::DB which ties a tree to a table in a database, and Javascript::Menu which uses this tree to build menus for websites.
One more feature that the module implements for the ease of subclassing it is an API for adding and removing fields from trees and nodes.
Requirements:
Perl
Tree::Numbered 2.02 keywords