AVLTree Class (console safe)
In computer science, an AVL tree is the first-invented self-balancing binary search tree. In an AVL tree the heights of the two child subtrees of any node differ by at most one, therefore it is also known as height-balanced.
Lookup, insertion, and deletion are all O(log n) in both the average and worst cases. Additions and deletions may require the tree to be rebalanced by one or more tree rotations.
This class will act as a high speed dictionary where the Key type can be of various data-types given that the correct comparer class is provided for it. This class has built in integer and string comparers, but comparer for any data-type can be added to the class.
By nature AVLTree is sorted so this class has methods to get the contents of the class out in a format that is sorted by key either backwards or forwards. Getting the sorted contents requires no actual sorting or processing.
Each key in a AVLTree must be unique.
Object
AVLTree
class AVLTree
Constructors
AVLTree | Constructs a AVLTree that uses strings as keys. |
AVLTree | Constructs a AVLTree that uses strings or integers as keys. |
AVLTree | Constructs a AVLTree that uses a custom data-type as a Key. |
Properties
Count (console safe) | Returns the number of elements in the AVLTree. |
Methods
Add (console safe) | Adds a object to the tree by a given key. |
Clear (console safe) | Deletes all items from the tree. |
Exists (console safe) | Returns true if a given key exists in the tree. |
GetKeys (console safe) | Obtains all keys in the tree in a sorted order, either forwards or backwards. |
GetValues (console safe) | Obtains all values in the tree in a a order that is sorted by keys, either forwards or backwards. |
Item (console safe) | Sets or gets a value of a item in the tree by key. |
Remove (console safe) | Removes a item from the tree. |
Constants
IntegerCompareProc = 0 | This constant is to be used with one of the AVLTree constructors. This constant represents that a Integer comparison routine should be used. |
StringCompareProc = 1 | This constant is to be used with one of the AVLTree constructors. This constant represents that a String comparison routine should be used. |
Supported Platforms:
MacOS X CarbonMacOS X Cocoa 32 bitMacOS X Cocoa 64 bitWindows 32 bitWindows 64 bitLinux 32 bitLinux 64 bitLinux ARM