Example #1
0
        public static void BinarySearchValue_Odd()
        {
            Driver <RefX1 <int> > RefDriver = new Driver <RefX1 <int> >();

            RefX1 <int>[] intArr1 = new RefX1 <int> [99];
            for (int i = 0; i < 99; i++)
            {
                intArr1[i] = new RefX1 <int>(i);
            }

            //odd
            RefDriver.BinarySearch(intArr1);

            RefDriver.BinarySearchNegative(new RefX1 <int> [0], new RefX1 <int>[] { null }, new int[] { -1 });
            RefDriver.BinarySearchNegative(intArr1, new RefX1 <int>[] { null }, new int[] { -1 });
            RefDriver.BinarySearchNegative(intArr1, new RefX1 <int>[] { new RefX1 <int>(100) }, new int[] { -100 });

            intArr1[50] = new RefX1 <int>(49);
            RefDriver.BinarySearchNegative(intArr1, new RefX1 <int>[] { new RefX1 <int>(50) }, new int[] { -52 });

            RefDriver.BinarySearch(new RefX1 <int>[] { });
            RefDriver.BinarySearch(new RefX1 <int>[] { new RefX1 <int>(1) });
            RefDriver.BinarySearch(new RefX1 <int>[] { new RefX1 <int>(1), new RefX1 <int>(2) });
            RefDriver.BinarySearch(new RefX1 <int>[] { new RefX1 <int>(1), new RefX1 <int>(2), new RefX1 <int>(3) });
        }
Example #2
0
        public static void BinaryTreeValue_Even()
        {
            Driver <RefX1 <int> > RefDriver = new Driver <RefX1 <int> >();

            RefX1 <int>[] intArr1 = new RefX1 <int> [100];
            for (int i = 0; i < 100; i++)
            {
                intArr1[i] = new RefX1 <int>(i);
            }

            //even
            RefDriver.BinarySearch(intArr1);

            RefDriver.BinarySearchNegative(new RefX1 <int> [0], new RefX1 <int>[] { null }, new int[] { -1 });
            RefDriver.BinarySearchNegative(intArr1, new RefX1 <int>[] { null }, new int[] { -1 });
            RefDriver.BinarySearchNegative(intArr1, new RefX1 <int>[] { new RefX1 <int>(100) }, new int[] { -101 });

            intArr1[50] = new RefX1 <int>(49);
            RefDriver.BinarySearchNegative(intArr1, new RefX1 <int>[] { new RefX1 <int>(50) }, new int[] { -52 });

            intArr1 = new RefX1 <int> [99];
            for (int i = 0; i < 99; i++)
            {
                intArr1[i] = new RefX1 <int>(i);
            }
        }
Example #3
0
 public override bool Equals(object obj)
 {
     if (obj is RefX1 <T> )
     {
         RefX1 <T> v = (RefX1 <T>)obj;
         return(CompareTo(v) == 0);
     }
     return(false);
 }
Example #4
0
 public int CompareTo(RefX1 <T> obj)
 {
     if (null == obj)
     {
         return(1);
     }
     if (null == _val)
     {
         if (null == obj.Val)
         {
             return(0);
         }
         else
         {
             return(-1);
         }
     }
     return(_val.CompareTo(obj.Val));
 }
Example #5
0
 public bool Equals(RefX1 <T> x)
 {
     return(0 == CompareTo(x));
 }