/** * Searches a big array for the specified value using the binary search * algorithm. The range must be sorted prior to making this call. If it is not * sorted, the results are undefined. If the range contains multiple elements * with the specified value, there is no guarantee which one will be found. * * @param a * the big array to be searched. * @param key * the value to be searched for. * @return index of the search key, if it is contained in the big array; * otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion * point</i> is defined as the the point at which the value would be * inserted into the big array: the index of the first element greater * than the key, or the length of the big array, if all elements in the * big array are less than the specified key. Note that this guarantees * that the return value will be >= 0 if and only if the key is * found. * @see java.util.Arrays */ public static long binarySearch(final int[][] a, final int key) { return binarySearch(a, 0, IntBigArrays.length(a), key); } /**
/** * Searches a big array for the specified value using the binary search * algorithm and a specified comparator. The range must be sorted following the * comparator prior to making this call. If it is not sorted, the results are * undefined. If the range contains multiple elements with the specified value, * there is no guarantee which one will be found. * * @param a * the big array to be searched. * @param key * the value to be searched for. * @param c * a comparator. * @return index of the search key, if it is contained in the big array; * otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion * point</i> is defined as the the point at which the value would be * inserted into the big array: the index of the first element greater * than the key, or the length of the big array, if all elements in the * big array are less than the specified key. Note that this guarantees * that the return value will be >= 0 if and only if the key is * found. * @see java.util.Arrays */ public static long binarySearch(final int[][] a, final int key, final IntComparator c) { return binarySearch(a, 0, IntBigArrays.length(a), key, c); } /** The size of a digit used during radix sort (must be a power of 2). */