Temporal.Interval.Set
- Package
- purescript-temporal
- Repository
- philippedev101/purescript-temporal
Sorted, non-overlapping interval collections.
An IntervalSet maintains the invariant that its intervals are sorted by
start, non-overlapping, non-adjacent, and non-empty. All operations
preserve this invariant.
Use IntervalSet for scheduling, calendar free/busy queries, and timeline
operations.
#IntervalSet Source
newtype IntervalSet aA sorted collection of non-overlapping, non-adjacent, non-empty half-open intervals.
Instances
(EncodeJson a) => EncodeJson (IntervalSet a)(DecodeJson a) => DecodeJson (IntervalSet a)(Eq a) => Eq (IntervalSet a)(Show a) => Show (IntervalSet a)
#empty Source
empty :: forall a. IntervalSet aThe empty interval set.
#singleton Source
singleton :: forall a. Interval a -> IntervalSet aAn interval set containing a single interval.
#fromIntervals Source
fromIntervals :: forall a. Ord a => Array (Interval a) -> IntervalSet aBuild an interval set from an array of intervals, merging any that overlap or are adjacent. O(n log n).
#toArray Source
toArray :: forall a. IntervalSet a -> Array (Interval a)Extract the sorted array of non-overlapping intervals.
#isEmpty Source
isEmpty :: forall a. IntervalSet a -> BooleanWhether the set contains no intervals.
#span Source
span :: forall a. Ord a => IntervalSet a -> Maybe (Interval a)The bounding interval (from the earliest start to the latest end).
Returns Nothing for an empty set.
#member Source
member :: forall a. Ord a => a -> IntervalSet a -> BooleanWhether a point is contained in any interval in the set. O(log n).
#findContaining Source
findContaining :: forall a. Ord a => a -> IntervalSet a -> Maybe (Interval a)Find the interval containing the given point, if any. O(log n).
#gaps Source
gaps :: forall a. Ord a => IntervalSet a -> IntervalSet aThe gaps (free time) between intervals within the set's span. Returns an empty set if the set has fewer than 2 intervals.
#insert Source
insert :: forall a. Ord a => Interval a -> IntervalSet a -> IntervalSet aInsert an interval into the set, merging with any overlapping or adjacent existing intervals. O(n).
#remove Source
remove :: forall a. Ord a => Interval a -> IntervalSet a -> IntervalSet aRemove an interval from the set, punching holes as needed. O(n).
#unionSets Source
unionSets :: forall a. Ord a => IntervalSet a -> IntervalSet a -> IntervalSet aUnion of two interval sets. O(n + m).
#intersectSets Source
intersectSets :: forall a. Ord a => IntervalSet a -> IntervalSet a -> IntervalSet aIntersection of two interval sets — the time present in both. O(n + m).
#differenceSets Source
differenceSets :: forall a. Ord a => IntervalSet a -> IntervalSet a -> IntervalSet aDifference of two interval sets — time in the first but not the second. O(n + m).
#complement Source
complement :: forall a. Ord a => Interval a -> IntervalSet a -> IntervalSet aThe complement of an interval set within a bounding interval — the gaps relative to the bound.
complement [0, 100) { [10, 20), [50, 60) }
-- { [0, 10), [20, 50), [60, 100) }
- Modules
- Temporal.
Diff - Temporal.
Display - Temporal.
Duration - Temporal.
Duration. Extra - Temporal.
Format. Html - Temporal.
Instant - Temporal.
Instant. Extra - Temporal.
Internal. Options - Temporal.
Internal. Types - Temporal.
Internal. Unsafe - Temporal.
Interval - Temporal.
Interval. Duration - Temporal.
Interval. Set - Temporal.
Now - Temporal.
PlainDate - Temporal.
PlainDate. Boundary - Temporal.
PlainDate. Extra - Temporal.
PlainDate. Weekday - Temporal.
PlainDateTime - Temporal.
PlainDateTime. Extra - Temporal.
PlainMonthDay - Temporal.
PlainTime - Temporal.
PlainTime. Extra - Temporal.
PlainYearMonth - Temporal.
PlainYearMonth. Extra - Temporal.
Predicate - Temporal.
TimeDuration - Temporal.
ZonedDateTime - Temporal.
ZonedDateTime. Boundary - Temporal.
ZonedDateTime. Extra