code: private int findMin(Comparator comparator, int index, int len)
    {
      if (index >= heapSize) {
        return -1;
      }
      int limit = Math.min(index, heapSize - len) + len;
      int minIndex = index;
      for (int i = index + 1; i < limit; i++) {
        if (comparator.compare(buf.getInt(i * Integer.BYTES), buf.getInt(minIndex * Integer.BYTES)) < 0) {
          minIndex = i;
        }
      }
      return minIndex;
    }
docs: Returns the index of minimum value between {@code index} and
  {@code index + len}, or {@code -1} if {@code index} is greater than
  {@code size}.