A DatumRange is provided as a means to carry an ordered pair of Datums representing an interval. This sort of data structure comes up often in processing, and it's useful to define once and get the operators implemented correctly. Consider using this object whenever you see pairs of Datums in interfaces and codes (e.g. tbegin,tend), they are probably a DatumRange!
return a new DatumRange that includes the given Datum, extending the range if necessary. For example,
[0,1).include(2)→ [0,2) (note this is exclusive of 2 since it's the end). [0,1).include(-1)→ [-1,1). [0,1).include(0.5) → [0,1] (and returns the same DatumRange object)Also, including a fill Datum returns the same DatumRange as well.
returns the intersection of the two intersecting ranges. This is a range that contains(d) if and only if this.contains(d) and dr.contains(d).
returns true of the DatumRange overlaps this. Note that the endpoints are not included in the comparison, so that Tuesday.intersects(Wednesday)==false.
returns the middle value of the range, often useful when the most descriptive value is needed.
returns the previous DatumRange covering the space defined by Units. See next().
returns the union of the two intersecting or adjacent ranges.
returns the width of the range, which is simply the greater minus the lessor. Note that the units of the result will not necessarily be the same as the endpoints, for example with LocationDatums.
returns a scaled DatumRange, with a new width that is the this datumRange's width multiplied by factor, and the same center. 1.0 is the same range, 2.0 has twice the width, etc.