[Overview][Classes][Index] | Reference for unit 'AVL_Tree' (#fcl)

# TAVLTree

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

AVL tree component

## Declaration

Source position: avl_tree.pp line 65

`type TAVLTree = class`
`protected`
`fNodeMgrAutoFree: Boolean;`
`fNodeMgr: TBaseAVLTreeNodeManager;`
`public`
`Root: TAVLTreeNode;` |  | Root node of the tree
`function Find();` |  | Find a data item in the tree.
`function FindKey();` |  | Find a data item in the tree using alternate compare mechanism
`function FindSuccessor();` |  | Find successor to node
`function FindPrecessor();` |  |
`function FindLowest;` |  | Find the lowest (leftmost) node in the tree.
`function FindHighest;` |  | Find the highest (rightmost) node in the tree.
`function FindNearest();` |  | Find the node closest to the data in the tree
`function FindPointer();` |  | Search for a data pointer
`function FindLeftMost();` |  | Find the node most left to a specified data node
`function FindRightMost();` |  | Find the node most right to a specified node
`function FindLeftMostKey();` |  | Find the node most left to a specified key node
`function FindRightMostKey();` |  | Find the node most right to a specified key node
`function FindLeftMostSameKey();` |  | Find the node most left to a specified node with the same data
`function FindRightMostSameKey();` |  | Find the node most right of a specified node with the same data
`procedure Add();` |  | Add a new node to the tree
`procedure Delete();` |  | Delete a node from the tree
`procedure Remove();` |  | Remove a data item from the list.
`procedure RemovePointer();` |  | Remove a pointer item from the list.
`procedure MoveDataLeftMost();` |  | Move data to the nearest left element
`procedure MoveDataRightMost();` |  | Move data to the nearest right element
`property OnCompare: TListSortCompare; [rw]` |  | Compare function used when comparing nodes
`procedure Clear;` |  | Clears the tree
`procedure FreeAndClear;` |  | Clears the tree and frees nodes
`procedure FreeAndDelete();` |  | Delete a node from the tree and destroy it
`property Count: Integer; [r]` |  | Number of nodes in the tree.
`function ConsistencyCheck;` |  | Check the consistency of the tree
`procedure WriteReportToStream();` |  | Write the contents of the tree consistency check to the stream
`function ReportAsString;` |  | Return the tree report as a string
`procedure SetNodeManager();` |  | Set the node instance manager to use
`procedure Create();` |  | Create a new instance of TAVLTree
`destructor Destroy; override;` |  | Destroy the TAVLTree instance
`function GetEnumerator;` |  | Get an enumerator for the tree.
`end;`

## Inheritance

`TAVLTree` |  | AVL tree component
`TObject`

## Description

TAVLTree maintains a balanced AVL tree. The tree consists of TAVLTreeNode nodes, each of which has a Data pointer associated with it. The TAVLTree component offers methods to balance and search the tree.

By default, the list is searched with a simple pointer comparison algorithm, but a custom search mechanism can be specified in the OnCompare property.

## See also

TAVLTreeNode |  | Represents a node in the tree.

The latest version of this document can be found at lazarus-ccr.sourceforge.net .