of_delnode


pfcapsrv.pbl   >   pfc_n_cst_tree   >   of_delnode   

Full name pfc_n_cst_tree.of_delnode
Access protected
Extend of integer
Return value integer
Prototype protected function integer of_delnode(n_cst_treenode,ref n_cst_treenode,ref boolean)

Name Datatype
No Data

Name Datatype
li_compare integer
lnv_left n_cst_treenode
lnv_right n_cst_treenode
lnv_temp n_cst_treenode

protected function integer of_delnode (n_cst_treenode anv_keynode, ref n_cst_treenode anv_currentnode, ref boolean ab_height);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_delnode
//
//	Access:  protected
//
//	Arguments : 
//	anv_keynode n_cst_treenode : contains the node to be deleted
//	anv_currentnode n_cst_treenode : Node to be examined
//	ab_height boolean : indicates whether the 'height; of the tree has changed or not
//
//	Returns:  integer
//	1 : Node was deleted
//	-1 : invalid node passed in or node not found
//
//	Description: 
//	Delete the node from the tree whose key matched the node passed
//	in the anv_keynode parameter. Deletion of the node may cause
//	the tree to be re-balanced.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	6.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996-1997 Sybase, Inc. and its subsidiaries.  All rights reserved.
//	Any distribution of the PowerBuilder Foundation Classes (PFC)
//	source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

integer li_compare
n_cst_treenode lnv_temp
n_cst_treenode lnv_right
n_cst_treenode lnv_left

if not isvalid(anv_currentnode) then
	ab_height = false
	return -1
else
	li_compare = inv_compare.of_compare(anv_keynode,anv_currentnode)
	if li_compare = inv_compare.LESSTHAN then
		anv_currentnode.of_getprev(lnv_temp)
		of_delnode(anv_keynode,lnv_temp,ab_height)
		anv_currentnode.of_setprev(lnv_temp)
		if ab_height then of_balanceleft(anv_currentnode,ab_height)
	elseif li_compare = inv_compare.GREATERTHAN  then
		anv_currentnode.of_getnext(lnv_temp)
		of_delnode(anv_keynode,lnv_temp,ab_height)
		anv_currentnode.of_setnext(lnv_temp)
		if ab_height then of_balanceright(anv_currentnode,ab_height)
	else // delete anv_currentnode
		inv_shiftnode = anv_currentnode
		inv_shiftnode.of_getnext(lnv_right)
		inv_shiftnode.of_getprev(lnv_left)
		if not isvalid(lnv_right) then
			anv_currentnode = lnv_left
			ab_height = true
		elseif not isvalid(lnv_left) then
			anv_currentnode = lnv_right
			ab_height = true
		else
			of_balance(lnv_left,ab_height)
			inv_shiftnode.of_setprev(lnv_left)
			if ab_height then of_balanceleft(anv_currentnode,ab_height)
		end if
	end if
end if
return 1

end function

     
Name Owner
pfc_n_cst_tree.of_delnode pfc_n_cst_tree
pfc_n_cst_tree.of_remove pfc_n_cst_tree

     
Name Owner
systemfunctions.isvalid systemfunctions
pfc_n_cst_nodecomparebase.of_compare pfc_n_cst_nodecomparebase
pfc_n_cst_tree.of_balanceleft pfc_n_cst_tree
pfc_n_cst_tree.of_balanceright pfc_n_cst_tree
pfc_n_cst_tree.of_delnode pfc_n_cst_tree
pfc_n_cst_tree.of_balance pfc_n_cst_tree
pfc_n_cst_nodebase.of_setprev pfc_n_cst_nodebase
pfc_n_cst_nodebase.of_setnext pfc_n_cst_nodebase
pfc_n_cst_nodebase.of_getnext pfc_n_cst_nodebase
pfc_n_cst_nodebase.of_getprev pfc_n_cst_nodebase

     
Full name
No Data

     
Name Scope
No Data