Schedule

object Schedule

Contains all key functions for managing Schedules.

Companion
class
trait Product
trait Mirror
class Object
trait Matchable
class Any

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Inherited from
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Inherited from
Mirror

Value members

Concrete methods

@tailrec
def add(start: Long, end: Long, tasks: List[(Long, Long)], result: Queue[(Long, Long)]): Option[List[(Long, Long)]]

Adds an interval to a list of intervals.

Adds an interval to a list of intervals.

Fails and returns scala.None if the new interval clashes with any of the existing intervals, i.e. there is overlapping time.

Value Params
end

The end timestamp of the interval.

result

The accumulated result so far (for tail recursion).

start

The start timestamp of the interval.

tasks

The list of intervals to add to.

Returns

Some updated list of intervals, or scala.None if there was an overlap.

See also
Example

add(3, 5, List((1,2), (6,7))) == Some(List((1,2), (3,5), (6,7)))

add(3, 5, List((1,3), (6,7))) == Some(List((1,5), (6,7)))

add(3, 5, List((1,4), (6,7))) == None

Shorthand for an empty schedule.

Shorthand for an empty schedule.

Returns

An empty Schedule.

Creates a Schedule from a TaskResource based on its currently running TaskInstance (if any).

Creates a Schedule from a TaskResource based on its currently running TaskInstance (if any).

Value Params
r

The TaskResource to schedule for.

Returns

The initialised schedule.

@tailrec
def fit(start: Long, duration: Long, tasks: List[(Long, Long)]): Long

Finds the earliest time when a fixed task duration can fit into a list of busy intervals.

Finds the earliest time when a fixed task duration can fit into a list of busy intervals.

A fixed duration fits at a particular starting time t if the interval (t, t+duration) has no overlap with the existing intervals in the list. It can '''always''' fit after the end of the last interval in the list, but the function returns the earliest possible start.

Value Params
duration

The task duration to consider.

start

The initial starting time to check for.

tasks

The list of intervals to check against.

Returns

The earliest possible start for the given task duration.

See also
Example

fit(0, 2, List((0,2), (3,4), (6,7))) == 4

fit(0, 2, List((0,2), (3,4), (5,7))) == 7

fit(0, 2, List((2,4), (5,7))) == 0

@tailrec
def isValid(gaps: List[(Long, Long)], end: Long): Boolean

Checks if a list of intervals is valid

Checks if a list of intervals is valid

For it to be valid it must:

  1. Contain valid intervals, i.e. intervals with a start that is strictly before the end.
  2. The intervals are strictly ordered, i.e. the start of an interval is always strictly after the end of the previous one.
Value Params
end

The current end timestamp to check against (for tail recursion).

gaps

The list of intervals.

@tailrec
def merge(g1: List[(Long, Long)], g2: List[(Long, Long)], result: Queue[(Long, Long)]): List[(Long, Long)]

Merges two lists of intervals into one.

Merges two lists of intervals into one.

Intervals that overlap partially or fully, or are adjacent (the end time of one is the start time of the other) are merged into one interval.

Value Params
g1

The first list of intervals to merge.

g2

The second list of intervals to merge.

result

The accumulated result so far (for tail recursion).

Returns

The merged list of intervals.

See also
Example

merge(List((1,2), (5,6)), List((3,4))) == List((1,2), (3,4), (5,6))

merge(List((1,2), (3,5)), List((2,4))) == List((1,5))

def mergeSchedules(schedules: Seq[Schedule]): Schedule

Merges a sequence of Schedules using Schedule.++.

Merges a sequence of Schedules using Schedule.++.

Value Params
schedules

The sequence of schedules to merge.

Returns

The merged schedule.

Deprecated methods

@deprecated("No longer using gaps in Schedule", "1.2.0")
def fitInGaps(start: Long, end: Long, gaps: List[(Long, Long)], result: Queue[(Long, Long)]): Option[List[(Long, Long)]]
Deprecated
@deprecated("No longer using gaps in Schedule", "1.2.0")
def mergeGaps(g1: List[(Long, Long)], g2: List[(Long, Long)], result: Queue[(Long, Long)]): List[(Long, Long)]
Deprecated