CoreClasses Xojo Plugin

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

AVLTreeConstructs a AVLTree that uses strings as keys.
AVLTreeConstructs a AVLTree that uses strings or integers as keys.
AVLTreeConstructs a AVLTree that uses a custom data-type as a Key.

Properties

CountReturns the number of elements in the AVLTree.

Methods

AddAdds a object to the tree by a given key.
ClearDeletes all items from the tree.
ExistsReturns true if a given key exists in the tree.
GetKeysObtains all keys in the tree in a sorted order, either forwards or backwards.
GetValuesObtains all values in the tree in a a order that is sorted by keys, either forwards or backwards.
ItemSets or gets a value of a item in the tree by key.
RemoveRemoves a item from the tree.

Constants

IntegerCompareProc = 0This constant is to be used with one of the AVLTree constructors. This constant represents that a Integer comparison routine should be used.
StringCompareProc = 1This 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 Intel 64 bit
  • macOS Apple Silicon
  • Windows 32 bit
  • Windows 64 bit
  • Windows ARM 64 bit
  • Linux 32 bit
  • Linux 64 bit
  • Linux ARM 32 bit
  • Linux ARM 64 bit
  • iOS