예제 #1
0
 public override bool Equals(object obj)
 {
     if (obj is ValX1 <T> )
     {
         ValX1 <T> v = (ValX1 <T>)obj;
         return(CompareTo(v) == 0);
     }
     return(false);
 }
예제 #2
0
        public int CompareTo(ValX1 <T> obj)
        {
            if (Object.ReferenceEquals(_val, obj._val))
            {
                return(0);
            }

            if (null == _val)
            {
                return(-1);
            }

            return(_val.CompareTo(obj.Val));
        }
예제 #3
0
        public static void BinarySearchRef_Even()
        {
            Driver <ValX1 <int> > ValDriver = new Driver <ValX1 <int> >();

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

            //even
            ValDriver.BinarySearch(vintArr1);

            ValDriver.BinarySearchNegative(new ValX1 <int> [0], new ValX1 <int>[] { new ValX1 <int>(-1) }, new int[] { -1 });
            ValDriver.BinarySearchNegative(vintArr1, new ValX1 <int>[] { new ValX1 <int>(-1) }, new int[] { -1 });
            ValDriver.BinarySearchNegative(vintArr1, new ValX1 <int>[] { new ValX1 <int>(100) }, new int[] { -101 });

            vintArr1[50] = new ValX1 <int>(49);
            ValDriver.BinarySearchNegative(vintArr1, new ValX1 <int>[] { new ValX1 <int>(50) }, new int[] { -52 });
        }
예제 #4
0
        public static void BinarySearchRef_Odd()
        {
            Driver <ValX1 <int> > ValDriver = new Driver <ValX1 <int> >();

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

            //odd
            ValDriver.BinarySearch(vintArr1);
            ValDriver.BinarySearchNegative(vintArr1, new ValX1 <int>[] { new ValX1 <int>(-1) }, new int[] { -1 });
            ValDriver.BinarySearchNegative(vintArr1, new ValX1 <int>[] { new ValX1 <int>(100) }, new int[] { -100 });
            vintArr1[50] = new ValX1 <int>(49);
            ValDriver.BinarySearchNegative(vintArr1, new ValX1 <int>[] { new ValX1 <int>(50) }, new int[] { -52 });

            ValDriver.BinarySearch(new ValX1 <int>[] { });
            ValDriver.BinarySearch(new ValX1 <int>[] { new ValX1 <int>(1) });
            ValDriver.BinarySearch(new ValX1 <int>[] { new ValX1 <int>(1), new ValX1 <int>(2) });
            ValDriver.BinarySearch(new ValX1 <int>[] { new ValX1 <int>(1), new ValX1 <int>(2), new ValX1 <int>(3) });
        }
예제 #5
0
 public bool Equals(ValX1 <T> x)
 {
     return(0 == CompareTo(x));
 }