Skip to main content

destructNodeAndAllChilds

Short summary

destructs / deepdestructs all nodes in the subtrees of a specified node and this node

Parameters

NameTypeCommentKind
nodeCNM_CollectionInterfaces.IBinaryTreeNodethe node that should be destructed with all it's childsinput

Code

Declaration

METHOD PROTECTED FINAL destructNodeAndAllChilds
VAR_INPUT
(*the node that should be destructed with all it's childs*)
node :CNM_CollectionInterfaces.IBinaryTreeNode;
END_VAR
VAR CONSTANT
OBJECT_NOT_REFERENCED :__XWORD := 0;
END_VAR

Implementation

RETURN(THIS^.isObjectNull(node));
IF THIS^.isObjectValid(node.leftChild) THEN
THIS^.destructNodeAndAllChilds(node := node.leftChild);
node.leftChild := OBJECT_NOT_REFERENCED;
END_IF
IF THIS^.isObjectValid(node.rightChild) THEN
THIS^.destructNodeAndAllChilds(node := node.rightChild);
node.rightChild := OBJECT_NOT_REFERENCED;
END_IF
node.destruct();