Skip to main content

adaptBalanceAfterDoubleRotation

Short summary

after a double rotation balance have to be adopted

Parameters

NameTypeCommentKind
elemCNM_CollectionInterfaces.IBalancedBinarySearchTreeNodethe element for that childs balance should be adaptedinput

Code

Declaration

METHOD PROTECTED adaptBalanceAfterDoubleRotation
VAR_INPUT
(*the element for that childs balance should be adapted*)
elem :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode;
END_VAR
VAR
leftChild :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode;
rightChild :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode;
END_VAR

Implementation

__QUERYINTERFACE(elem.leftChild,leftChild);
__QUERYINTERFACE(elem.rightChild,rightChild);

CASE elem.balance OF
CNM_CollectionInterfaces.TreeBalance.LEFTDEEPER:
leftChild.balance := CNM_CollectionInterfaces.TreeBalance.EQUALDEEP;
rightChild.balance := CNM_CollectionInterfaces.TreeBalance.RIGHTDEEPER;
CNM_CollectionInterfaces.TreeBalance.RIGHTDEEPER:
leftChild.balance := CNM_CollectionInterfaces.TreeBalance.LEFTDEEPER;
rightChild.balance := CNM_CollectionInterfaces.TreeBalance.EQUALDEEP;
CNM_CollectionInterfaces.TreeBalance.EQUALDEEP:
leftChild.balance := CNM_CollectionInterfaces.TreeBalance.EQUALDEEP;
rightChild.balance := CNM_CollectionInterfaces.TreeBalance.EQUALDEEP;

END_CASE