code: static <V> int find(Comparator<V> comparator, Object key, Object[] a, final int fromIndex, final int toIndex)
      {
          int low = fromIndex;
          int high = toIndex - 1;
  
          while (low <= high)
          {
              int mid = (low + high) / 2;
              int cmp = comparator.compare((V) key, (V) a[mid]);
  
              if (cmp > 0)
                  low = mid + 1;
              else if (cmp < 0)
                  high = mid - 1;
              else
                  return mid; // key found
          }
          return -(low + 1);  // key not found.
      }
docs: wrapping generic Comparator with support for Special +/- infinity sentinels