of_remove


pfcapsrv.pbl   >   pfc_n_cst_linkedlistbase   >   of_remove   

Full name pfc_n_cst_linkedlistbase.of_remove
Access protected
Extend of integer
Return value integer
Prototype protected function integer of_remove(ref n_cst_linkedlistnode)

Name Datatype
No Data

Name Datatype
lnv_next n_cst_linkedlistnode
lnv_previous n_cst_linkedlistnode

protected function integer of_remove (ref n_cst_linkedlistnode anv_removenode);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_Remove
//
//	Access:  protected
//
//	Arguments : 
//	anv_removenode  (by ref) The actual node to be removed from the list.
//
//	Returns:  integer
//	1 = success
//	-1 = failure
//
//	Description:  
//	Removes the passed in node from the list, resetting any nodes previous 
//	and after that point to it.  Also clearing its own Next and Previous 
//	pointers.
//
//////////////////////////////////////////////////////////////////////////////
//
//	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.
//
//////////////////////////////////////////////////////////////////////////////

n_cst_linkedlistnode lnv_previous
n_cst_linkedlistnode lnv_next

// Validate parameter.
if IsNull(anv_removenode) or Not IsValid(anv_removenode) then 
	return -1 
end if

// Determine if there is only one node in the list.
if inv_tail = inv_head then
	If anv_removenode = inv_head then 
		// -- Removing the only node. --
		// Clear its pointers.
		anv_removenode.of_SetNext(inv_nil)
		anv_removenode.of_SetPrev(inv_nil)
		// Clear the Head and Tail pointers.
		inv_head = inv_nil
		inv_tail = inv_nil
		return 1
	End If
	// Node not found.
	return -1
end if

// Check to see if it is the current Head node.
if anv_removenode = inv_head then 
	anv_removenode.of_getnext(lnv_next)
	if isnull(lnv_next) or not isvalid(lnv_next) then 
		// Pointer should be pointing at a valid node.
		return -1
	end if 
	// Clear its pointers.
	anv_removenode.of_SetNext(inv_nil)
	anv_removenode.of_SetPrev(inv_nil)	
	// Set the reference to the new Head node.
	inv_head = lnv_next
	inv_head.of_setprev(inv_nil)
	return 1
end if

// Check to see if it is the Tail node.
if anv_removenode = inv_tail then 
	anv_removenode.of_getprev(lnv_previous)
	if isnull(lnv_previous) or not isvalid(lnv_previous) then 
		// Pointer should be pointing at a valid node.
		return -1 
	end if
	// Clear its pointers.
	anv_removenode.of_SetNext(inv_nil)
	anv_removenode.of_SetPrev(inv_nil)	
	// Set the reference to the new Head node.	
	inv_tail = lnv_previous
	inv_tail.of_setnext(inv_nil)
	return 1
end if

// -- It is not the Head nor the Tail node. --
// -- There should be a previous and a next node. --

// Get the previous node.
anv_removenode.of_getprev(lnv_previous)
if isnull(lnv_previous) or not isvalid(lnv_previous) then 
	// Pointer should be pointing at a valid node.
	return -1 
end if

// Get the next node.
anv_removenode.of_getnext(lnv_next)
if isnull(lnv_next) or not isvalid(lnv_next) then 
	// Pointer should be pointing at a valid node.
	return -1 
end if

// Set the valid pointers to the previous and next pointers to remove the 
// passed in node.
lnv_previous.of_setnext(lnv_next)
lnv_next.of_setprev(lnv_previous)

// Clear its pointers.
anv_removenode.of_SetNext(inv_nil)
anv_removenode.of_SetPrev(inv_nil)	
return 1
end function

     
Name Owner
pfc_n_cst_stack.of_pop pfc_n_cst_stack
pfc_n_cst_queue.of_get pfc_n_cst_queue
pfc_n_cst_linkedlistbase.of_destroy pfc_n_cst_linkedlistbase
pfc_n_cst_linkedlistbase.of_removehead pfc_n_cst_linkedlistbase
pfc_n_cst_linkedlistbase.of_removetail pfc_n_cst_linkedlistbase
pfc_n_cst_list.of_remove pfc_n_cst_list

     
Name Owner
systemfunctions.isnull systemfunctions
systemfunctions.isvalid systemfunctions
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