Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ MakeBalanced()

static SortedInt32KeyNode< TValue > System.Collections.Immutable.SortedInt32KeyNode< TValue >.MakeBalanced ( SortedInt32KeyNode< TValue > tree)
inlinestaticprivate

Definition at line 310 of file SortedInt32KeyNode.cs.

311 {
312 Requires.NotNull(tree, "tree");
313 if (IsRightHeavy(tree))
314 {
315 if (Balance(tree._right) >= 0)
316 {
317 return RotateLeft(tree);
318 }
319 return DoubleLeft(tree);
320 }
321 if (IsLeftHeavy(tree))
322 {
323 if (Balance(tree._left) <= 0)
324 {
325 return RotateRight(tree);
326 }
327 return DoubleRight(tree);
328 }
329 return tree;
330 }
static bool IsRightHeavy(SortedInt32KeyNode< TValue > tree)
static bool IsLeftHeavy(SortedInt32KeyNode< TValue > tree)
static SortedInt32KeyNode< TValue > DoubleRight(SortedInt32KeyNode< TValue > tree)
static int Balance(SortedInt32KeyNode< TValue > tree)
static SortedInt32KeyNode< TValue > RotateLeft(SortedInt32KeyNode< TValue > tree)
static SortedInt32KeyNode< TValue > DoubleLeft(SortedInt32KeyNode< TValue > tree)
static SortedInt32KeyNode< TValue > RotateRight(SortedInt32KeyNode< TValue > tree)

References System.Collections.Immutable.SortedInt32KeyNode< TValue >.Balance(), System.Collections.Immutable.SortedInt32KeyNode< TValue >.DoubleLeft(), System.Collections.Immutable.SortedInt32KeyNode< TValue >.DoubleRight(), System.Collections.Immutable.SortedInt32KeyNode< TValue >.IsLeftHeavy(), System.Collections.Immutable.SortedInt32KeyNode< TValue >.IsRightHeavy(), System.Collections.Immutable.SortedInt32KeyNode< TValue >.RotateLeft(), and System.Collections.Immutable.SortedInt32KeyNode< TValue >.RotateRight().

Referenced by System.Collections.Immutable.SortedInt32KeyNode< TValue >.RemoveRecursive(), and System.Collections.Immutable.SortedInt32KeyNode< TValue >.SetOrAdd().