docs: private void negateRange(final short[] buffer, final int startIndex, final int lastIndex,
        final int startRange, final int lastRange) {
      // compute the negation into buffer
  
      int outPos = 0;
      int inPos = startIndex; // value here always >= valInRange,
      // until it is exhausted
      // n.b., we can start initially exhausted.
  
      int valInRange = startRange;
      for (; valInRange < lastRange && inPos <= lastIndex; ++valInRange) {
        if ((short) valInRange != content[inPos]) {
          buffer[outPos++] = (short) valInRange;
        } else {
          ++inPos;
        }
      }
  
      // if there are extra items (greater than the biggest
      // pre-existing one in range), buffer them
      for (; valInRange < lastRange; ++valInRange) {
        buffer[outPos++] = (short) valInRange;
      }
  
      if (outPos != buffer.length) {
        throw new RuntimeException(
            "negateRange: outPos " + outPos + " whereas buffer.length=" + buffer.length);
      }
      // copy back from buffer...caller must ensure there is room
      int i = startIndex;
      for (short item : buffer) {
        content[i++] = item;
      }
    }