jammy (3) Paranoid::Data::AVLTree.3pm.gz

Provided by: libparanoid-perl_2.09-1_all bug

NAME

       Paranoid::Data::AVLTree - AVL-Balanced Tree Class

VERSION

       $Id: lib/Paranoid/Data/AVLTree.pm, 2.09 2021/12/28 15:46:49 acorliss Exp $

SYNOPSIS

           # Preferred use
           tie %tree, 'Paranoid::Data::AVLTree';

           # Or, purely as an object
           $tree   = new Paranoid::Data::AVLTree;
           $count  = $tree->count;
           $height = $tree->height;
           @keys   = $tree->nodeKeys;
           $rv     = $tree->nodeExists($key):
           $val    = $tree->fetchVal($key);
           $rv     = $tree->addPair($key, $value);
           $rv     = $tree->delNode($key);
           $rv     = $tree->purgeNodes;
           $tree->dumpKeys;

DESCRIPTION

       This class provides an AVL-balance tree implementation, that can work both as an independent object or as
       a tied hash.  Future versions will include methods to allow for simple spooling to and from disk.

SUBROUTINES/METHODS

   new
           $tree   = new Paranoid::Data::AVLTree;

       This creates a new tree object.

   count
           $count  = $tree->count;

       This method returns a count of all the nodes in the tree.

   height
           $height = $tree->height;

       This method returns the height of the tree.

   nodeKeys
           @keys   = $tree->nodeKeys;

       This method returns a list of all keys for all nodes in the tree.

   nodeExists
           $rv     = $tree->nodeExists($key):

       This method returns a boolean value indicating whether a node exists wtih a matching key.

   fetchVal
           $val    = $tree->fetchVal($key);

       This method returns the associated value for the passed key.  Like hashes, it will return undef for
       nonexistant keys.

   addPair
           $rv     = $tree->addPair($key, $value);

       This method adds the requested key/value pair, or updates an existing node with the same key.  It will
       return a boolean false if the key is an invalid value.

   delNode
           $rv     = $tree->delNode($key);

       This method deletes the specified node if it exists.  It will return boolean false should no matching
       node exist.

   purgeNodes
           $rv     = $tree->purgeNodes;

       This purges all nodes from the tree.

   dumpKeys
           $tree->dumpKeys;

       This method exists purely for diagnostic purposes.  It dumps a formatted tree structure to STDERR showing
       all keys in the tree, along with the relative branch height and balance of every node, along with what
       side of the tree each node is attached.

   TIE METHODS
       These methods aren't intended for direct use, but to support tied hashes.

       CLEAR

       DELETE

       EXISTS

       FETCH

       FIRSTKEY

       NEXTKEY

       SCALAR

       STORE

       TIEHASH

       UNTIE

DEPENDENCIES

       o   Carp

       o   Paranoid

       o   Paranoid::Debug

       o   Paranoid::Data::AVLTree::AVLNode

BUGS AND LIMITATIONS

AUTHOR

       Arthur Corliss (corliss@digitalmages.com)

       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)