docs: private static int upper_bound(int first, int last, int x, IntComparator comp) {
  	//if (comp==null) throw new NullPointerException();
  	int len = last - first;
  	while (len > 0) {
  		int half = len / 2;
  		int middle = first + half;
  		if (comp.compare(x, middle)<0) {
  			len = half;
  		}
  		else {
  			first = middle + 1;
  			len -= half + 1;
  		}
  	}
  	return first;
  }