An Average Level Tree structure, which is kept balanced so that finding a node is very rapid
TAvgLvlTreeNode
- a node, the basic structural element of a TAvgLvlTree
Parent
- the previous level in the tree
The Left descendant branch node in the tree
The Right descendant branch node in the tree
Balance
- should be 0 for perfect balance, -1 or +1 for one extra node on either side, more than (+ or -) 1 means tree is unbalanced and needs to be fixed
A pointer to the actual Data associated with the node
Clear
- remove all the branches leaving an empty tree
TreeDepth
- the number of levels in the tree structure, by the longest way down
PAvgLvlTreeNode
- pointer to a TAvgLvlTreeNode
TAvgLvlTree
- an Average Level binary Tree
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))
Root
- the starting node of the tree structure
Compare two data. For every two nodes of the tree holds: Compare(Left,Right)
Find node with a Data of the same key. The found Node.Data need not be the same as the Data parameter.
Search a node with the same key. OnCompareKeyWithData first parameter is the key, second the Node.Data.
Find the next node to the right with the next higher value.
Find the next node to the left with the next lower value.
Find the left most node.
Find the right most node.
Find a node with the same key. If no node with exact the same key exists a node left or right is returned.
As Find, but Key and Data must be the same.
As FindKey, but if there are several nodes with the same key, the left most is returned
As FindKey, but if there are several nodes with the same key, the right most is returned
Starts at ANode and returns the left most node with the same key as ANode.
Starts at ANode and returns the left most node with the same key as ANode.
Adds a node to the tree
Removes and frees a node. The data is not freed (See FreeAndDelete).
if the Data with the same key exists one node is removed.
RemovePointer - if the Data with the same pointer exists one pointer is removed.
If there are several nodes with the same Key as ANode, the node is moved left most of this group.
If there are several nodes with the same Key as ANode, the node is moved right most of this group.
OnCompare
- user-supplied event handler to define your own sorting. The tree will be rebuilt without losing data.
Same as OnCompare, but with a method instead of a procedure.
Delete all nodes without freeing the data. Calls Clear then performs inherited Destroy
Delete all nodes and call TObject(Node.Data).Free on every data.
Call TObject(ANode.Data).Free then delete the node.
Count
- number of nodes
ConsistencyCheck
- checks that the root node exists and that the tree is correctly balanced with valid nodes on each level
WriteReportToStream
- sends a status report to the current data stream
ReportAsString
returns the status report sent to the stream, as a string
Create
- constructor for TAvgLvlTree, allowing the comparison method to be passed as an argument. Performs Inherited Create and copies the specified comparison method to a local variable
Version of the Create constructor without specified arguments
Destroy
- destructor for TAvgLvlTree:
PAvgLvlTree
- a pointer to a TAvgLvlTree
TAvgLvlTreeNodeMemManager
- memory manager for TAvgLvlTree nodes
DisposeNode
- method for disposal of a node when it is no longer needed
NewNode
- returns a new node fo the structure
MinimumFreeNode
the value of the smallest (or next) free node
MaximumFreeNodeRatio
- the maximum allowable ratio of free nodes
Count
- the running total of nodes
Clear
- remove all the nodes and leave an empty structure
Create
- constructor for TAvgLvlTreeNodeMemManager: calls inherited Create then initialises the counters
TObject.Create
Destroy
- destructor for memory manager: calls Clear then performs inherited Destroy
TObject.Destroy
Same as FindKey, but if the exact Key can not be found a Node left or right of it is returned.
TPointerToPointerItem
- an item in a PointerToPointer Tree (associative array)
The Key defining the pointer item
The Value of the pointer item
PPointerToPointerItem
- a pointer to a TPointerToPointerItem
TPointerToPointerTree
- an associative array of PointerToPointer Items, or a tree of trees
TPointerToPointerTree
- an associative array of PointerToPointer Items, or a tree of trees. This class uses pointers to identify pointers within the array, unlike the TStringToStringTree, which uses strings to identify strings.
Create
- constructor for TPointerToPointerTree. Calls the TAvgLvlTree.Create method
TAvgLvlTree.Create
TObject.Destroy
Destroy
- destructor for TPointerToPointerTree: Clear the tree, Free the items then call inherited Destroy
Clear
- removes each node from the tree, leaving an empty tree
Remove
the node specified by Key from the tree
Returns True if the tree Contains the node specified by Key
GetFirst
- finds the first node matching the supplied arguments; returns True if successful
GetLast
- finds the last node matching the supplied arguments; returns True if successful
GetNext
- finds the next node matching the supplied arguments; returns True if successful
GetPrev
- finds the previous node matching the supplied arguments; returns True if successful
Count
- the number of items
Values
- a pointer into the array of values associated with the nodes
The Tree that forms the basis of the associative array
TStringToStringTree
- an associative array of StringToString Items, or a tree of trees. This class uses strings to identify strings within the array, unlike the TPointerToPointerTree, which uses pointers to identify pointers.
TStringToStringTree
- an associative array of StringToString Items, or a tree of trees
TStringToStringItem
- an item in a StringToString Tree (associative array)
The Name that identifies the string within the associative array
The Value of the string held within the associative array
PStringToStringItem
- pointer to a TStringToStringItem
The instance of the Create constructor that allows the programmer to specify whether or not the string operations are to be Case Sensitive
TObject.Create
CaseSensitive
- if True, string operations (comparisons etc) must be case sensitive
The instance of the Create constructor that allows the programmer to specify how items in the list are to be compared
TObject.Create
Destroy
- destructor for TStringToStringTree: calls Clear, frees items then calls inherited Destroy
Clear
- removes all items leaving an empty tree
Returns True if the tree Contains the specified string
Add
an item to the tree (specified by its name, value or delimiter)
AddNameValues
add the specified named values to the tree
AddValues
- adds the specified values to the tree
GetFirst
- finds the matching first item; returns True if successful
GetLast
- finds the last matching item; returns True if successful
GetNext
- finds the next matching item; returns True if successful
GetPrev
- finds the previous matching item; returns True if successful
Count
- the number of items
The Values of the strings corresponding to the supplied name
The Tree that forms the basis of the associative array
CompareItems
- the items for comparison
CompareNameWithItem
- the name for comparison with the item
The default enumerator over the nodes from left to right, low to high