docs: private void negateRange(final ShortBuffer 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.get(inPos)) {
          buffer.put(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.put(outPos++, (short) valInRange);
      }
  
      if (outPos != buffer.limit()) {
        throw new RuntimeException(
            "negateRange: outPos " + outPos + " whereas buffer.length=" + buffer.limit());
      }
      assert outPos == buffer.limit();
      // copy back from buffer...caller must ensure there is room
      int i = startIndex;
      int len = buffer.limit();
      for (int k = 0; k < len; ++k) {
        final short item = buffer.get(k);
        content.put(i++, item);
      }
    }