Skip to main content

rotateLeft

Short summary

rotates a tree around a node

Return: the new root

Parameters

NameTypeCommentKind
elemCNM_CollectionInterfaces.IBalancedBinarySearchTreeNodeThe element that sould be rotatet aroundinput

Code

Declaration

METHOD PROTECTED rotateLeft :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode
VAR_INPUT
(*The element that sould be rotatet around*)
elem :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode;
END_VAR
VAR
newRoot :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode;
END_VAR

Implementation

__QUERYINTERFACE(elem.rightChild, newRoot);
elem.rightChild := newRoot.leftChild;
newRoot.leftChild := elem;
rotateLeft := newRoot;