Example #1
0
 private AvlTree(IBinarySearchTree <K, V> left, K key, V value, IBinarySearchTree <K, V> right) : this()
 {
     myLeft   = left ?? AvlTree <K, V> .Empty;
     myKey    = key;
     myValue  = value;
     myRight  = right ?? AvlTree <K, V> .Empty;
     myIsLeaf = myLeft.IsEmpty && myRight.IsEmpty;
     unchecked {
         myHashCode += myLeft.GetHashCode();
         if (!System.Object.ReferenceEquals(null, key))
         {
             myHashCode += key.GetHashCode();
         }
         if (!System.Object.ReferenceEquals(null, value))
         {
             myHashCode += value.GetHashCode();
         }
         myHashCode += myRight.GetHashCode();
     }
     myHeight = 1 + System.Math.Max(myLeft.Height, myRight.Height);
 }