Ron Savage > Tree > Tree::Binary2

Download:
Tree-1.05.tgz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.05   Source  

NAME ^

Tree::Binary2 - An implementation of a binary tree

SYNOPSIS ^

  my $tree = Tree::Binary2->new( 'root' );

  my $left = Tree::Binary2->new( 'left' );
  $tree->left( $left );

  my $right = Tree::Binary2->new( 'left' );
  $tree->right( $right );

  my $right_child = $tree->right;

  $tree->right( undef ); # Unset the right child.

  my @nodes = $tree->traverse( $tree->POST_ORDER );

  my $traversal = $tree->traverse( $tree->IN_ORDER );
  while ( my $node = $traversal->() ) {
      # Do something with $node here
  }

DESCRIPTION ^

This is an implementation of a binary tree. This class inherits from Tree, which is an N-ary tree implemenation. Because of this, this class actually provides an implementation of a complete binary tree vs. a sparse binary tree. The empty nodes are instances of Tree::Null, which is described in Tree. This should have no effect on your usage of this class.

METHODS ^

In addition to the methods provided by Tree, the following items are provided or overriden.

NOTE: You have access to all the methods provided by Tree, but it is not recommended that you use many of them, unless you know what you're doing. This list includes add_child() and remove_child().

TODO ^

CODE COVERAGE ^

Please see the relevant sections of Tree.

SUPPORT ^

Please see the relevant sections of Tree.

AUTHORS ^

Rob Kinyon <rob.kinyon@iinteractive.com>

Stevan Little <stevan.little@iinteractive.com>

Thanks to Infinity Interactive for generously donating our time.

COPYRIGHT AND LICENSE ^

Copyright 2004, 2005 by Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: