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
- Return type: CNM_ReturnTypes.SingleExecutionResult
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| object | CNM_AbstractObject.IObject | the object that should be wrapped | input |
| node | CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode | the created tree node container element | output |
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