[Overview][Types][Classes][Procedures and functions][Index] Reference for unit 'AvgLvlTree' (#lcl)

TAvgLvlTree

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

TAvgLvlTree - an Average Level binary Tree

Declaration

Source position: avglvltree.pas line 56

type TAvgLvlTree = class

public

  Root: TAvgLvlTreeNode;

  

Root - the starting node of the tree structure

  function Compare();

  

Compare two data. For every two nodes of the tree holds: Compare(Left,Right)

  function Find();

  

Find node with a Data of the same key. The found Node.Data need not be the same as the Data parameter.

  function FindKey();

  

Search a node with the same key. OnCompareKeyWithData first parameter is the key, second the Node.Data.

  function FindNearestKey();

  

Same as FindKey, but if the exact Key can not be found a Node left or right of it is returned.

  function FindSuccessor();

  

Find the next node to the right with the next higher value.

  function FindPrecessor();

  

Find the next node to the left with the next lower value.

  function FindLowest;

  

Find the left most node.

  function FindHighest;

  

Find the right most node.

  function FindNearest();

  

Find a node with the same key. If no node with exact the same key exists a node left or right is returned.

  function FindPointer();

  

As Find, but Key and Data must be the same.

  function FindLeftMost();

  

  function FindRightMost();

  

  function FindLeftMostKey();

  

As FindKey, but if there are several nodes with the same key, the left most is returned

  function FindRightMostKey();

  

As FindKey, but if there are several nodes with the same key, the right most is returned

  function FindLeftMostSameKey();

  

Starts at ANode and returns the left most node with the same key as ANode.

  function FindRightMostSameKey();

  

Starts at ANode and returns the left most node with the same key as ANode.

  procedure Add();

  

  procedure Delete();

  

Removes and frees a node. The data is not freed (See FreeAndDelete).

  procedure Remove();

  

if the Data with the same key exists one node is removed.

  procedure RemovePointer();

  

RemovePointer - if the Data with the same pointer exists one pointer is removed.

  procedure MoveDataLeftMost();

  

If there are several nodes with the same Key as ANode, the node is moved left most of this group.

  procedure MoveDataRightMost();

  

If there are several nodes with the same Key as ANode, the node is moved right most of this group.

  property OnCompare: TListSortCompare; [rw]

  

OnCompare - user-supplied event handler to define your own sorting. The tree will be rebuilt without losing data.

  property OnObjectCompare: TObjectSortCompare; [rw]

  

Same as OnCompare, but with a method instead of a procedure.

  procedure Clear;

  

Delete all nodes without freeing the data. Calls Clear then performs inherited Destroy

  procedure FreeAndClear;

  

Delete all nodes and call TObject(Node.Data).Free on every data.

  procedure FreeAndDelete();

  

Call TObject(ANode.Data).Free then delete the node.

  property Count: Integer; [r]

  

Count - number of nodes

  function ConsistencyCheck;

  

ConsistencyCheck - checks that the root node exists and that the tree is correctly balanced with valid nodes on each level

  procedure WriteReportToStream();

  

WriteReportToStream - sends a status report to the current data stream

  function ReportAsString;

  

ReportAsString returns the status report sent to the stream, as a string

  property NodeMemManager: TAvgLvlTreeNodeMemManager; [rw]

  procedure Create();

  

Version of the Create constructor without specified arguments

  constructor CreateObjectCompare();

  

  destructor Destroy; override;

  

Destroy - destructor for TAvgLvlTree:

end;

Inheritance

TAvgLvlTree

  

TAvgLvlTree - an Average Level binary Tree

|

TObject

Description

TAvgLvlTree is an Average Level binary Tree. This binary tree is always balanced, so that inserting, deleting and finding a node is performed in O(log(#Nodes))

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