/** * Searches an 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 array to be searched. * @param key * the value to be searched for. * @return index of the search key, if it is contained in the array; otherwise, * {@code (-(<i>insertion point</i>) - 1)}. The <i>insertion point</i> * is defined as the the point at which the value would be inserted into * the array: the index of the first element greater than the key, or * the length of the array, if all elements in the 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 int binarySearch(final long[] a, final long key) { return binarySearch(a, 0, a.length, key); } /**
/** * Searches an 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 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 array; otherwise, * {@code (-(<i>insertion point</i>) - 1)}. The <i>insertion point</i> * is defined as the the point at which the value would be inserted into * the array: the index of the first element greater than the key, or * the length of the array, if all elements in the 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 int binarySearch(final long[] a, final long key, final LongComparator c) { return binarySearch(a, 0, a.length, key, c); } /** The size of a digit used during radix sort (must be a power of 2). */
final int from0 = x; //Math.min(x, succ[i]); final int to0 = succ[i]; //Math.max(x, succ[i]); final int edge0 = LongArrays.binarySearch(edge, 0, edgesSoFar, ((long)from0 << 32) | to0); if (ASSERTS) assert edge0 >= 0; final int dNext = g.outdegree(to0); final int from1 = to0; //Math.min(x, succ[j]); final int to1 = succNext[j]; //Math.max(x, succ[j]); final int edge1 = LongArrays.binarySearch(edge, 0, edgesSoFar, ((long)from1 << 32) | to1); if (ASSERTS) assert edge1 >= 0; if (currBatch == batchSize) {