Skip to main content

getNewBBSTreeNode

Short summary

function to create a new balanced binary searchtree node

Return: SingleExecutionResult.SUCCESS: allocation succesful, output node contains new tree node instance SingleExecutionResult.ERROR: error during allocation, output node is NULL

Parameters

NameTypeCommentKind
objectCNM_AbstractObject.IObjectthe object that should be wrappedinput
nodeCNM_CollectionInterfaces.IBalancedBinarySearchTreeNodethe created tree node container elementoutput

Code

Declaration

METHOD getNewBBSTreeNode :CNM_ReturnTypes.SingleExecutionResult 
VAR_INPUT
(* the object that should be wrapped *)
object :CNM_AbstractObject.IObject;
END_VAR
VAR_OUTPUT
(* the created tree node container element *)
node :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode;
END_VAR
VAR
newTreeNode :POINTER TO BalancedBinarySearchTreeNode;
END_VAR
VAR CONSTANT
IS_NOT_REFERENCED :__XWORD := 0;
END_VAR

Implementation

getNewBBSTreeNode := CNM_ReturnTypes.SingleExecutionResult.ERROR;
newTreeNode := __NEW(
BalancedBinarySearchTreeNode(
value := object,
left := IS_NOT_REFERENCED,
right := IS_NOT_REFERENCED
)
);
IF (newTreeNode <> 0) THEN
newTreeNode^.leftChild := IS_NOT_REFERENCED;
newTreeNode^.rightChild := IS_NOT_REFERENCED;
node := newTreeNode^;
getNewBBSTreeNode := CNM_ReturnTypes.SingleExecutionResult.SUCCESS;
END_IF