/** Append the diff at the end of the list. */ private D addLast(D diff) { createDiffsIfNeeded(); final D last = getLast(); diffs.addLast(diff); if (last != null) { last.setPosterior(diff); } return diff; }
/** Add the diff to the beginning of the list. */ final void addFirst(D diff) { createDiffsIfNeeded(); final D first = diffs.isEmpty()? null : diffs.get(0); diffs.addFirst(diff); diff.setPosterior(first); }