/// <summary> /// Finds the first and last indexes of a specific element within a sorted list. /// <summary> /// <returns>int[]</returns> /// <param name="list">cern.colt.list.DoubleArrayList</param> /// <param name="element">the element to search for</param> protected static IntArrayList BinaryMultiSearch(DoubleArrayList list, double element) { int index = list.BinarySearch(element); if (index < 0) { return(null); //not found } int from = index - 1; while (from >= 0 && list[from] == element) { from--; } from++; int to = index + 1; while (to < list.Count && list[to] == element) { to++; } to--; return(new IntArrayList(new int[] { from, to })); }
/// <summary> /// Returns whether the specified element is contained in the receiver. /// </summary> /// <param name="element"></param> /// <returns></returns> public Boolean Contains(double element) { this.Sort(); return(buffer.BinarySearch(element) >= 0); }