Tree::MultiNodeA multi node tree object. | |
Download |
Tree::MultiNode Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Kyle R. Burton, Daniel X. Pape and Eric Joanis
- Publisher web site:
- http://search.cpan.org/~krburton/
Tree::MultiNode Tags
Tree::MultiNode Description
A multi node tree object. Tree::MultiNode is a multi node tree object. Most useful for modeling heirarchial data structures.SYNOPSIS use Tree::MultiNode; use strict; use warnings; my $tree = new Tree::MultiNode; my $handle = new Tree::MultiNode::Handle($tree); $handle->set_key("top"); $handle->set_value("level"); $handle->add_child("child","1"); $handle->add_child("child","2"); $handle->first(); $handle->down(); $handle->add_child("grandchild","1-1"); $handle->up(); $handle->last(); $handle->down(); $handle->add_child("grandchild","2-1"); $handle->up(); $handle->top(); &dump_tree($handle); my $depth = 0; sub dump_tree { ++$depth; my $handle = shift; my $lead = ' ' x ($depth*2); my($key,$val); ($key,$val) = $handle->get_data(); print $lead, "key: $key "; print $lead, "val: $val "; print $lead, "depth: $depth "; my $i; for( $i = 0; $i < scalar($handle->children); ++$i ) { $handle->down($i); &dump_tree($handle); $handle->up(); } --$depth; }Tree::MultiNode, Tree::MultiNode::Node, and MultiNode::Handle are objects modeled after C++ classes that I had written to help me model heirarchical information as datastructures (such as the relationships between records in an RDBMS). The tree is basicly a list of lists type data structure, where each node has a key, a value, and a list of children. The tree has no internal sorting, though all operations perserve the order of the child nodes. Requirements: · Perl
Tree::MultiNode Related Software