Unit 'AVL_Tree' Package
[Overview][Types][Classes][Variables][Index] [#fcl]

TAVLTree.AddAscendingSequence

Declaration

Source position: avl_tree.pp line 128

public function TAVLTree.AddAscendingSequence(

  Data: Pointer;

  LastAdded: TAVLTreeNode;

  var Successor: TAVLTreeNode

):TAVLTreeNode;

Arguments

Data

  

Data to insert.

LastAdded

  

Last added node. Must initially be Nil.

Successor

  

Successor node. Must initially be Nil.

Function result

The newly inserted node.

Description

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.

Errors

If the nodes are not in ascending order, the tree will not be consistent.

See also

TAVLTree.Add

  

Add a new node to the tree.


Documentation generated on: Nov 23 2024