Sign in Join
FPDoc Onlineexperiment

TAVLTree class

In unit AVL_Tree

AVL tree component.

Declaration

pascal
TAVLTree = class

Descends from it: TAvgLvlTree

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

Properties

NodeClasspublicNode class to create.
RootpublicRoot node of the tree.
CountpublicNumber of nodes in the tree.

Methods

BalanceAfterInsertprotected
BalanceAfterDeleteprotected
DeletingNodeprotected
FindInsertPosprotected
Initprotected
NodeAddedprotected
RotateLeftprotected
RotateRightprotected
SwitchPositionWithSuccessorprotected
SetOnCompareprotected
SetOnObjectCompareprotected
SetComparesprotected
SetNodeClassprotected
CreatepublicCreate a new instance of TAVLTree.
CreateObjectComparepublicCreate an instance of the tree with extended compare method.
DestroypublicDestroy the TAVLTree instance.
SetNodeManagerpublicSet the node instance manager to use.
NewNodepublicCreate a new tree node.
DisposeNodepublicDispose of a node outside of the tree.
AddpublicAdd a new node to the tree.
AddAscendingSequencepublic
DeletepublicDelete a node from the tree.
RemovepublicRemove a data item from the list.
RemovePointerpublicRemove a pointer item from the list.
MoveDataLeftMostpublicMove data to the nearest left element.
MoveDataRightMostpublicMove data to the nearest right element.
ClearpublicClears the tree.
FreeAndClearpublicClears the tree and frees nodes.
FreeAndDeletepublicDelete a node from the tree and destroy it.
EqualspublicCheck if two trees are equal.
IsEqualpublicCheck whether 2 tree instances are equal.
AssignpublicAssign another tree.
ComparepublicCompare 2 nodes.
FindpublicFind a data item in the tree.
FindKeypublicFind a data item in the tree using alternate compare mechanism.
FindNearestKeypublicFind nearest key for a data pointer.
FindSuccessorpublicFind successor to node.
FindPrecessorpublic
FindLowestpublicFind the lowest (leftmost) node in the tree.
FindHighestpublicFind the highest (rightmost) node in the tree.
FindNearestpublicFind the node closest to the data in the tree.
FindPointerpublicSearch for a data pointer.
FindLeftMostpublicFind the node most left to a specified data node.
FindRightMostpublicFind the node most right to a specified node.
FindLeftMostKeypublicFind the node most left to a specified key node.
FindRightMostKeypublicFind the node most right to a specified key node.
FindLeftMostSameKeypublicFind the node most left to a specified node with the same data.
FindRightMostSameKeypublicFind the node most right of a specified node with the same data.
GetEnumeratorpublicGet an enumerator for the tree.
GetEnumeratorHighToLowpublicReturn an enumerator that enumerates the tree in reversed order.
ConsistencyCheckpublicCheck the consistency of the tree.
WriteReportToStreampublicWrite the contents of the tree consistency check to the stream.
NodeToReportStrpublicCreate a textual dump of the tree.
ReportAsStringpublicReturn the tree report as a string.

Events

OnComparepublicCompare function used when comparing nodes.
OnObjectComparepublicCompare handler.

Fields

FCountprotected
FNodeClassprotected
fNodeMgrprotected
fNodeMgrAutoFreeprotected
FOnCompareprotected
FOnObjectCompareprotected
FRootprotected

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.