Class: TimeIntervalCollection

TimeIntervalCollection

new TimeIntervalCollection(intervalsopt)

A non-overlapping collection of TimeInterval instances sorted by start time.
Parameters:
Name Type Attributes Description
intervals Array.<TimeInterval> <optional>
An array of intervals to add to the collection.
Source:

Members

(readonly) changedEvent :Event

Gets an event that is raised whenever the collection of intervals change.
Type:
Source:

(readonly) isEmpty :Boolean

Gets whether or not the collection is empty.
Type:
  • Boolean
Source:

(readonly) isStartIncluded :Boolean

Gets whether or not the start time is included in the collection.
Type:
  • Boolean
Source:

(readonly) isStopIncluded :Boolean

Gets whether or not the stop time is included in the collection.
Type:
  • Boolean
Source:

(readonly) length :Number

Gets the number of intervals in the collection.
Type:
  • Number
Source:

(readonly) start :JulianDate

Gets the start time of the collection.
Type:
Source:

(readonly) stop :JulianDate

Gets the stop time of the collection.
Type:
Source:

Methods

addInterval(interval, dataCompareropt)

Adds an interval to the collection, merging intervals that contain the same data and splitting intervals of different data as needed in order to maintain a non-overlapping collection. The data in the new interval takes precedence over any existing intervals in the collection.
Parameters:
Name Type Attributes Description
interval TimeInterval The interval to add.
dataComparer TimeInterval~DataComparer <optional>
A function which compares the data of the two intervals. If omitted, reference equality is used.
Source:

contains(julianDate) → {Boolean}

Checks if the specified date is inside this collection.
Parameters:
Name Type Description
julianDate JulianDate The date to check.
Source:
Returns:
true if the collection contains the specified date, false otherwise.
Type
Boolean

equals(rightopt, dataCompareropt) → {Boolean}

Compares this instance against the provided instance componentwise and returns true if they are equal, false otherwise.
Parameters:
Name Type Attributes Description
right TimeIntervalCollection <optional>
The right hand side collection.
dataComparer TimeInterval~DataComparer <optional>
A function which compares the data of the two intervals. If omitted, reference equality is used.
Source:
Returns:
true if they are equal, false otherwise.
Type
Boolean

findDataForIntervalContainingDate(date) → {Object}

Finds and returns the data for the interval that contains the specified date.
Parameters:
Name Type Description
date JulianDate The date to search for.
Source:
Returns:
The data for the interval containing the specified date, or undefined if no such interval exists.
Type
Object

findInterval(optionsopt) → {TimeInterval}

Returns the first interval in the collection that matches the specified parameters. All parameters are optional and undefined parameters are treated as a don't care condition.
Parameters:
Name Type Attributes Description
options Object <optional>
Object with the following properties:
Properties
Name Type Attributes Description
start JulianDate <optional>
The start time of the interval.
stop JulianDate <optional>
The stop time of the interval.
isStartIncluded Boolean <optional>
true if options.start is included in the interval, false otherwise.
isStopIncluded Boolean <optional>
true if options.stop is included in the interval, false otherwise.
Source:
Returns:
The first interval in the collection that matches the specified parameters.
Type
TimeInterval

findIntervalContainingDate(date) → {TimeInterval|undefined}

Finds and returns the interval that contains the specified date.
Parameters:
Name Type Description
date JulianDate The date to search for.
Source:
Returns:
The interval containing the specified date, undefined if no such interval exists.
Type
TimeInterval | undefined

get(index) → {TimeInterval}

Gets the interval at the specified index.
Parameters:
Name Type Description
index Number The index of the interval to retrieve.
Source:
Returns:
The interval at the specified index, or undefined if no interval exists as that index.
Type
TimeInterval

indexOf(date) → {Number}

Finds and returns the index of the interval in the collection that contains the specified date.
Parameters:
Name Type Description
date JulianDate The date to search for.
Source:
Returns:
The index of the interval that contains the specified date, if no such interval exists, it returns a negative number which is the bitwise complement of the index of the next interval that starts after the date, or if no interval starts after the specified date, the bitwise complement of the length of the collection.
Type
Number

intersect(other, dataCompareropt, mergeCallbackopt) → {TimeIntervalCollection}

Creates a new instance that is the intersection of this collection and the provided collection.
Parameters:
Name Type Attributes Description
other TimeIntervalCollection The collection to intersect with.
dataComparer TimeInterval~DataComparer <optional>
A function which compares the data of the two intervals. If omitted, reference equality is used.
mergeCallback TimeInterval~MergeCallback <optional>
A function which merges the data of the two intervals. If omitted, the data from the left interval will be used.
Source:
Returns:
A new TimeIntervalCollection which is the intersection of this collection and the provided collection.
Type
TimeIntervalCollection

removeAll()

Removes all intervals from the collection.
Source:

removeInterval(interval)

Removes the specified interval from this interval collection, creating a hole over the specified interval. The data property of the input interval is ignored.
Parameters:
Name Type Description
interval TimeInterval The interval to remove.
Source:
Returns:
true if the interval was removed, false if no part of the interval was in the collection.