private static int binarySearch(final int[] set, int startOffset, int endOffset, int key) {
    int low = startOffset;
    int high = endOffset - 1;

    while (low <= high) {
      int mid = low + high >>> 1;
      int midVal = Math.abs(set[mid]);

      if (midVal < key)
        low = mid + 1;
      else if (midVal > key)
        high = mid - 1;
      else
        return mid; // key found
    }
    return -(low + 1);  // key not found.
  }
private static int binarySearch(final int[] set, int startOffset, int endOffset, int key)