Source position: avl_tree.pp line 128
public function TAVLTree.AddAscendingSequence( |
Data: Pointer; |
LastAdded: TAVLTreeNode; |
var Successor: TAVLTreeNode |
):TAVLTreeNode; |
Data |
|
Data to insert. |
LastAdded |
|
Last added node. Must initially be Nil. |
Successor |
|
Successor node. Must initially be Nil. |
The newly inserted node.
AddAscendingSequence is an optimized version of Add for quickly adding an ascending sequence of nodes. It adds Data between LastAdded and Successor as a state and skips searching for an insert position. For nodes with same value the order of the sequence is kept.
It can be used as follows:
LastNode:=nil; // TAvlTreeNode Successor:=nil; // TAvlTreeNode or:=1 to 1000 do LastNode:=Tree.AddAscendingSequence(TItem.Create(i),LastNode,Successor);
If LastAdded is Nil a regular add is performed.
If the nodes are not in ascending order, the tree will not be consistent.
|
Add a new node to the tree. |