|
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
|
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