public override bool Equals(object obj) { if (obj is ValX1 <T> ) { ValX1 <T> v = (ValX1 <T>)obj; return(CompareTo(v) == 0); } return(false); }
public int CompareTo(ValX1 <T> obj) { if (Object.ReferenceEquals(_val, obj._val)) { return(0); } if (null == _val) { return(-1); } return(_val.CompareTo(obj.Val)); }
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 }); }
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) }); }
public bool Equals(ValX1 <T> x) { return(0 == CompareTo(x)); }