Run Tree
A RunTree maintains a mapping from Long to some value which is expected to be the same for runs of consecutive Longs. This is not thread-safe, and should be protected with an external ReadWriteLock to allow readers and writers to coordinate safely.
The null value is treated as the absence of a run. The edit method takes two Longs representing the affected range (degenerate ranges have no effect) and a function taking a Value or null, and returning a Value or null to use in its place. The function is evaluated zero or more times to produce edits of existing runs, which will then be subject to the RunTree`s normalization rules:
No empty ranges,
No
nullvalues in ranges,No overlapping ranges,
Two contiguous ranges will not have the same Value, by equality.
Ranges are not allowed to include Long.MAX_VALUE.
In addition, the RunTree is Iterable, allowing traversal over the triples in ascending order.
Author
Mark van Gulik
Constructors
Functions
Properties
The basic representation is a TreeMap from each run's start to a Pair containing the position just past the run's end and the value associated with that run. This is maintained in such a way that no runs overlap, no runs are empty, and there are no contiguous runs with equal values (they are automatically merged).