- BUGS AND LIMITATIONS
- LICENSE AND COPYRIGHT
Paranoid::Data::AVLTree - AVL-Balanced Tree Class
$Id: lib/Paranoid/Data/AVLTree.pm, 2.08 2020/12/31 12:10:06 acorliss Exp $
# 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;
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.
$tree = new Paranoid::Data::AVLTree;
This creates a new tree object.
$count = $tree->count;
This method returns a count of all the nodes in the tree.
$height = $tree->height;
This method returns the height of the tree.
@keys = $tree->nodeKeys;
This method returns a list of all keys for all nodes in the tree.
$rv = $tree->nodeExists($key):
This method returns a boolean value indicating whether a node exists wtih a matching key.
$val = $tree->fetchVal($key);
This method returns the associated value for the passed key. Like hashes, it will return undef for nonexistant keys.
$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.
$rv = $tree->delNode($key);
This method deletes the specified node if it exists. It will return boolean false should no matching node exist.
$rv = $tree->purgeNodes;
This purges all nodes from the tree.
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.
These methods aren't intended for direct use, but to support tied hashes.
Arthur Corliss (firstname.lastname@example.org)
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 (email@example.com) (tm) 2008 - 2020, Paranoid Inc. (www.paranoid.com)