private void addChange(int value) {
    if (value < 0) {
      if (!hasRemovals) hasRemovals = true;
    }
    else if (!mayHaveDupes && length > 0 && changes[length - 1] >= value) {
      //quite simple heuristics:
      // if (last added element >= currently added element)
      // => elements are added out-of-order => it may be duplicates
      mayHaveDupes = true;
    }
    changes[length++] = value;
  }
private void addChange(int value)