Example #1
0
            public bool Contains(T value)
            {
                int result = value.CompareTo(_data);

                if (result == 0)
                {
                    return(true);
                }
                if (result < 0 && LeftChild != null && LeftChild.Contains(value))
                {
                    return(true);
                }
                if (result > 0 && RightChild != null && RightChild.Contains(value))
                {
                    return(true);
                }
                return(false);
            }
Example #2
0
 public override bool Contains(T item)
 {
     if (item.CompareTo(Value) == 0)
     {
         return(true);
     }
     else if (LeftChild.GetType() == typeof(Branch <T>) || RightChild.GetType() == typeof(Branch <T>))
     {
         if (item.CompareTo(Value) == -1)
         {
             return(LeftChild.Contains(item));
         }
         else
         {
             return(RightChild.Contains(item));
         }
     }
     else
     {
         return(false);
     }
 }