range

A range between the given points. It will select a positive event at
the start time, or a negative one at the end time. Effectively it's
half-open from the start for Positive events, and half-open from the end
for Negative ones.

Range

A range between the given points. It will select a positive event at
the start time, or a negative one at the end time. Effectively it's
half-open from the start for Positive events, and half-open from the end
for Negative ones.

Clip overlapping event durations. An event with duration overlapping
another event will be clipped. Positive events are clipped by following
events, and negative ones are clipped by previous ones. In the event of
a conflict between positive and negative, they are both clipped to the
middle of the overlap. This may seem a bit weird, but it has the nice
properties that I never clip an event to 0, and never have to drop an
event due to clipping. From an implementation point of view, it lets me
write a single-pass algorithm.

If there are multiple events with the same start and orientation, the last
one wins.

The precondition is that the input events are sorted by event_key, the
postcondition is that they are still sorted and no [pos .. pos+dur) ranges
will overlap.