Interval

data class Interval @JvmOverloads constructor(val start: Duration, val end: Duration, val startInclusivity: Interval.Inclusivity = Inclusivity.Inclusive, val endInclusivity: Interval.Inclusivity = startInclusivity) : IntervalLike<Interval>

An Interval on the timeline, represented by start and end points and start and end inclusivity.

Constructors

Link copied to clipboard
constructor(start: Duration, end: Duration, startInclusivity: Interval.Inclusivity = Inclusivity.Inclusive, endInclusivity: Interval.Inclusivity = startInclusivity)

Types

Link copied to clipboard
object Companion

Helper functions for constructing Intervals.

Link copied to clipboard

Labels to indicate whether an interval includes its endpoints.

Properties

Link copied to clipboard
val end: Duration
Link copied to clipboard

Whether this interval contains its end time.

Link copied to clipboard
val start: Duration
Link copied to clipboard

Whether this interval contains its start time.

Functions

Link copied to clipboard
infix fun adjacentTo(x: Interval): Boolean

Whether this interval meets or is metBy another.

Link copied to clipboard
fun compareEnds(other: Interval): Int

Compare the end times of this and another interval.

Link copied to clipboard

Compares the end of this interval to the start of another interval.

Link copied to clipboard

Compare the start times of this and another interval.

Link copied to clipboard
Link copied to clipboard
operator fun contains(x: Interval): Boolean

Whether this interval contains the entirety of another.

operator fun contains(d: Duration): Boolean

Whether a given time is contained in this interval.

Link copied to clipboard
fun duration(): Duration

Length of the interval, represented as a Duration object.

Link copied to clipboard
infix fun hasSameEndAs(other: Interval): Boolean

Whether this and another interval end at the same time, accounting for inclusivity.

Link copied to clipboard
infix fun hasSameStartAs(other: Interval): Boolean

Whether this and another interval start at the same time, accounting for inclusivity.

Link copied to clipboard
infix fun hull(other: Interval): Interval

The smallest interval that contains both this and another interval.

Link copied to clipboard

Whether this interval includes its end point.

Link copied to clipboard

Whether this interval includes its start point.

Link copied to clipboard
infix fun intersection(other: Interval): Interval

Calculates the intersection between this interval and another.

Link copied to clipboard

Whether this interval contains any points.

Link copied to clipboard

Whether this interval contains only a single point.

Link copied to clipboard

Whether this interval happens after another interval with no overlap.

Link copied to clipboard

Whether this interval happens before another interval with no overlap.

Link copied to clipboard
infix fun meets(other: Interval): Boolean

Whether this interval precedes another and touches it without overlap.

Link copied to clipboard
infix fun metBy(other: Interval): Boolean

Whether this interval comes after another and touches it without overlap.

Link copied to clipboard
operator fun minus(other: Interval): List<Interval>

Removes all points in the argument interval from this interval. This is essentially the opposite of union.

Link copied to clipboard
fun shiftBy(shiftStart: Duration, shiftEnd: Duration = shiftStart): Interval

Shifts the start and end points equally forward or backward in time.

Link copied to clipboard
infix fun step(stride: Duration): Iterable<Duration>

Creates an iterable that produces durations spread out over the interval, separated by stride.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
infix fun union(other: Interval): List<Interval>

Calculates the union between this interval and another, as a list of intervals.