static void PushIfNotNull(Stack <AvlNode> stack, AvlNode?child) { if (child != null) { stack.Push(child); } }
private void PushIfNotNull(AvlNode?child) { if (child != null) { _stack.Push(child); } }
public static int AssertBalanced(AvlNode?V) { if (V == null) { return(0); } int a = AssertBalanced(V.Left); int b = AssertBalanced(V.Right); if (a - b != V.Balance || Math.Abs(a - b) >= 2) { throw new InvalidOperationException(); } return(1 + Math.Max(a, b)); }
#pragma warning disable CA1000 // Do not declare static members on generic types public static int AssertBalanced(AvlNode?V) #pragma warning restore CA1000 // Do not declare static members on generic types { if (V == null) { return(0); } int a = AssertBalanced(V.Left); int b = AssertBalanced(V.Right); if (a - b != V.Balance || Math.Abs(a - b) >= 2) { throw new InvalidOperationException(); } return(1 + Math.Max(a, b)); }