The type of the change can be observed from the combination of arguments.
- If something is going to be added
toBeAdded
is non-empty
and indexes
contain two indexes that are pointing to the position, e.g. {2, 2}
- If something is going to be removed, the
indexes
are paired by two:
from(inclusive)-to(exclusive) and are pointing to the current list.
E.g. if we remove 2,3,5 from list {0,1,2,3,4,5}, the indexes
will be {2, 4, 5, 6}. If there's more than one pair of indexes, toBeAdded
is always empty.
- for set
toBeAdded
contains 1 element and indexes
are like with removal: {index, index + 1}
- for setAll,
toBeAdded
contains all new elements and indexes
looks like this: {0, size()}
Note that it's always safe to iterate over toBeAdded and use indexes as pairs of
from-to, as there's always at least one pair.