logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

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

Author

       Arthur Corliss (corliss@digitalmages.com)

Bugs And Limitations

Dependencies

       o   Carp

       o   Paranoid

Description

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

Name

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

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.

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;

Version

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

See Also