Exemplo n.º 1
0
 static void PushIfNotNull(Stack <AvlNode> stack, AvlNode?child)
 {
     if (child != null)
     {
         stack.Push(child);
     }
 }
Exemplo n.º 2
0
 private void PushIfNotNull(AvlNode?child)
 {
     if (child != null)
     {
         _stack.Push(child);
     }
 }
Exemplo n.º 3
0
            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));
            }
Exemplo n.º 4
0
#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));
            }