getNewBBSTree
Short summary
This method can be used to dynamically create a __NEW binary balanced search tree.
Return: SingleExecutionResult.SUCCESS: allocation succesful, output tree contains new tree instance
SingleExecutionResult.ERROR: error during allocation, output tree is NULL
- Return type: CNM_ReturnTypes.SingleExecutionResult
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| comparator | CNM_AbstractObject.IComparator | optional custom comparator | input |
| tree | CNM_CollectionInterfaces.IBalancedBinarySearchTree | the created tree | output |
Code
Declaration
METHOD getNewBBSTree :CNM_ReturnTypes.SingleExecutionResult
VAR_INPUT
(*optional custom comparator*)
comparator : CNM_AbstractObject.IComparator := 0;
END_VAR
VAR_OUTPUT
(* the created tree *)
tree :CNM_CollectionInterfaces.IBalancedBinarySearchTree;
END_VAR
VAR
newBalancedBinarySearchTree :POINTER TO BalancedBinarySearchTree;
END_VAR
VAR CONSTANT
OBJECT_NOT_REFERENCED :__XWORD := 0;
END_VAR
Implementation
getNewBBSTree := CNM_ReturnTypes.SingleExecutionResult.ERROR;
IF THIS^.isObjectValid(comparator) THEN
newBalancedBinarySearchTree := __NEW(
BalancedBinarySearchTree(nodeComparator := comparator)
);
ELSE
newBalancedBinarySearchTree := __NEW(
BalancedBinarySearchTree(nodeComparator := OBJECT_NOT_REFERENCED)
);
END_IF
IF (newBalancedBinarySearchTree <> 0) THEN
tree := newBalancedBinarySearchTree^;
getNewBBSTree := CNM_ReturnTypes.SingleExecutionResult.SUCCESS;
END_IF