add method

UndoHeader<E> add(
  1. E entry,
  2. int i
)

Add the entry to the current branch. If we are a head, append it, otherwise appendAlt.

Implementation

UndoHeader<E> add(E entry, int i) {
  // We are at the tip of the tree, so we just append it
  if (next == null) {
    return append(entry, i);
  }
  // We need to add an new alt branch to the next element.
  return next!.appendAlt(entry, i);
}