Digital Mages

Digital Mages - Paranoid::Data::AVLTree::AVLNode(3)

Paranoid::Data::AVLTree::AVLNode

Section: User Contributed Perl Documentation (3)
Updated: 2022-03-08
Index  

NAME

Paranoid::Data::AVLTree::AVLNode - AVL Tree Node Object Class  

VERSION

$Id: lib/Paranoid/Data/AVLTree/AVLNode.pm, 2.10 2022/03/08 00:01:04 acorliss Exp $  

SYNOPSIS

    $node   = Paranoid::Data::AVLTree::AVLNode->new($key, $val);
    $key    = $node->key;
    $val    = $node->val;
    $rv     = $node->setVal($val);
    $ref    = $node->right;
    $rv     = $node->setRight($node);
    $ref    = $node->left;
    $rv     = $node->setLeft($node);
    $rv     = $node->incrRHeight;
    $rv     = $node->incrLHeight;
    $rv     = $node->addRHeight($n);
    $rv     = $node->addLHeight($n);
    $rv     = $node->decrRHeight;
    $rv     = $node->decrLHeight;
    $balance = $node->balance;
    $count  = $node->count;
    $height = $node->height;
    $height = $node->rHeight;
    $height = $node->lHeight;
    $rv     = $node->updtHeights;
    @crefs  = $node->children;

 

DESCRIPTION

This class provides the core data objects that comprise an AVL-balanced tree.  

SUBROUTINES/METHODS

 

new

    $node   = Paranoid::Data::AVLTree::AVLNode->new($key, $val);

This method creates a new AVLNode object. Like hashes, the key must be defined, but it cannot be a zero-length string. In those cases, this method will return undef.  

key

    $key    = $node->key;

This method returns the key for the node.  

val

    $val    = $node->val;

This method returns the associated value for the node. It can be undef.  

setVal

    $rv     = $node->setVal($val);

This method sets the assocated value for the node.  

right

    $ref    = $node->right;

This method retrieves a reference to the next right-side node in the branch, if any.  

setRight

    $rv     = $node->setRight($node);

This method sets/removes the reference to the next right-side node in the branch.  

left

    $ref    = $node->left;

This method retrieves a reference to the next left-side node in the branch, if any.  

setLeft

    $rv     = $node->setLeft($node);

This method sets/removes the reference to the next left-side node in the branch.  

incrRHeight

    $rv     = $node->incrRHeight;

This method increments the height counter for the ride-side sub-branch.  

incrLHeight

    $rv     = $node->incrLHeight;

This method increments the height counter for the left-side sub-branch.  

addRHeight

    $rv     = $node->addRHeight($n);

This method adds the passed value to the height counter for the right-side sub-branch.  

addLHeight

    $rv     = $node->addLHeight($n);

This method adds the passed value to the height counter for the left-side sub-branch.  

decrRHeight

    $rv     = $node->decrRHeight;

This method decrements the height counter for the right-side sub-branch.  

decrLHeight

    $rv     = $node->decrLHeight;

This method decrements the height counter for the left-side sub-branch.  

balance

    $balance = $node->balance;

This returns the node balance, which is a relative indidcator of the disparity in heights of the right & left sub-branches. A negative number denotes a longer left-side branch, zero means equal sub-branch heights, and a positive integer denotes a longer right-side branch.  

count

    $count  = $node->count;

This method returns the count of nodes, including all nodes in linked sub-branches.  

height

    $height = $node->height;

This method returns the longest height of the node and any attached sub-branches.  

rHeight

    $height = $node->rHeight;

This method returns the height of the right-side sub-branch, or zero if there is no linked branch.  

lHeight

    $height = $node->lHeight;

This method returns the height of the left-side sub-branch, or zero if there is no linked branch.  

updtHeights

    $rv     = $node->updtHeights;

This method performs a brute force recalculation of all attached sub-branches.  

children

    @crefs  = $node->children;

This returns references to the next nodes in any attadhed sub-branches.  

DEPENDENCIES

o
Carp
o
Paranoid
 

BUGS AND LIMITATIONS

 

AUTHOR

Arthur Corliss (corliss@digitalmages.com)  

LICENSE AND COPYRIGHT

This software is free software. Similar to Perl, you can redistribute it and/or modify it under the terms of either:

  a)     the GNU General Public License
         <https://www.gnu.org/licenses/gpl-1.0.html> as published by the 
         Free Software Foundation <http://www.fsf.org/>; either version 1
         <https://www.gnu.org/licenses/gpl-1.0.html>, or any later version
         <https://www.gnu.org/licenses/license-list.html#GNUGPL>, or
  b)     the Artistic License 2.0
         <https://opensource.org/licenses/Artistic-2.0>,

subject to the following additional term: No trademark rights to ``Paranoid'' have been or are conveyed under any of the above licenses. However, ``Paranoid'' may be used fairly to describe this unmodified software, in good faith, but not as a trademark.

(c) 2005 - 2020, Arthur Corliss (corliss@digitalmages.com) (tm) 2008 - 2020, Paranoid Inc. (www.paranoid.com)


 

Index

NAME
VERSION
SYNOPSIS
DESCRIPTION
SUBROUTINES/METHODS
new
key
val
setVal
right
setRight
left
setLeft
incrRHeight
incrLHeight
addRHeight
addLHeight
decrRHeight
decrLHeight
balance
count
height
rHeight
lHeight
updtHeights
children
DEPENDENCIES
BUGS AND LIMITATIONS
AUTHOR
LICENSE AND COPYRIGHT