|
of_addhead
|
|
Full name
|
pfc_n_cst_linkedlistbase.of_addhead
|
Access
|
protected
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
protected function integer of_addhead(n_cst_linkedlistnode)
|
protected function integer of_addhead (n_cst_linkedlistnode anv_newheadnode);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_AddHead
//
// Access: protected
//
// Arguments :
// anv_newheadnode The node to be added to the list as the new Head node.
//
// Returns: integer
// 1 = success
// -1 = failure
//
// Description:
// Adds a new node to the Head of the linked list.
//
//////////////////////////////////////////////////////////////////////////////
//
// 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.
//
//////////////////////////////////////////////////////////////////////////////
// Validate arguments.
if isnull(anv_newheadnode) or not isvalid(anv_newheadnode) then
return -1
end if
// See if this is the first node.
if isnull(inv_head) or not isvalid(inv_head) then
// This is the first node, so there is no previous or next pointers.
anv_newheadnode.of_setnext(inv_nil)
anv_newheadnode.of_setprev(inv_nil)
// Point the head and tail pointers.
inv_head = anv_newheadnode
inv_tail = inv_head
return 1
end if
// -- Add as the new Head Node. --
// Set the About to be New Head Next pointer to point to the Current Head.
anv_newheadnode.of_setnext(inv_head)
// Head nodes never have a previous pointer.
anv_newheadnode.of_setprev(inv_nil)
// Set the current Head previous pointer to the About to be New Head node.
inv_head.of_setprev(anv_newheadnode)
// Replace the current Head reference with the New Head node.
inv_head = anv_newheadnode
return 1
end function