private void registerUndoRedo(boolean undo, @Nullable IntList affectedChanges) {
    if (myUndoManager == null) return;

    List<S> states;
    if (affectedChanges != null) {
      states = new ArrayList<>(affectedChanges.size());
      affectedChanges.forEach((IntConsumer)(index) -> {
        states.add(storeChangeState(index));
      });
    }
    else {
      states = new ArrayList<>(getChangesCount());
      for (int index = 0; index < getChangesCount(); index++) {
        states.add(storeChangeState(index));
      }
    }
    myUndoManager.undoableActionPerformed(new MyUndoableAction(this, states, undo));
  }
private void registerUndoRedo(boolean undo, @Nullable IntList affectedChanges)