Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
day dividers: record the insert position when applying an operation b…
…ased on the previous item We could end up, like in the regression test, with a sequence of operations like that: - remove day divider @ i+1 (because it's redundant with one @ i) - remove day divider @ i (because it's useless, since the event before the day divider and after the day divider use the same date). In that case, it would break the non-decreasing invariant: we'd apply an operation on the array @ i+1, then @ i, which troubles the offset computation. Instead, when doing an operation based on the "prev_item" (now with a small helper struct, to facilitate understanding of each field), we also record the insertion order for the operation itself: it's always "at the end of the operation order, at the time we're looking at it", so equivalent to a "push_back" if there's no operation in between; but that ensures that we'll do the operation in a non-decreasing order. For instance in the above test case, the Remove(i) is now inserted before the Remove(i+1), instead of after.
- Loading branch information