Skip to main content

remove

Short summary

Method to remove an object from the tree.

Return: SUCCESS: if remove could be made ABORTED: if object wasn't in the tree ERROR: if object wasn't valid

Parameters

NameTypeCommentKind
objectCNM_AbstractObject.IObjectThe object that should be removedinput

Code

Declaration

METHOD INTERNAL remove :CNM_ReturnTypes.SingleExecutionResult
VAR_INPUT
(* The object that should be removed *)
object :CNM_AbstractObject.IObject;
END_VAR
VAR
heightNotChanged :BOOL := TRUE;
newRootNode :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode;
END_VAR

Implementation

newRootNode := THIS^.recursivRemove(
object:=object,
elem:=THIS^.rootNode,
heightNotChanged := heightNotChanged,
removeResult=>remove
);
IF remove = CNM_ReturnTypes.SingleExecutionResult.SUCCESS THEN
THIS^.decrementSize();
THIS^.announceChange();
THIS^.rootNode := newRootNode;
RETURN;
END_IF