IntervalMap-0.5.2.0: Containers for intervals, with efficient search.

Copyright(c) Christoph Breitkopf 2014
LicenseBSD-style
Maintainerchbreitkopf@gmail.com
Stabilityexperimental
Portabilitynon-portable (MPTC with FD)
Safe HaskellSafe
LanguageHaskell98

Data.IntervalMap.Generic.Interval

Contents

Description

Type class for IntervalMap keys.

As there is no sensible default, no instances for prelude types are provided (E.g. you might want to have tuples as closed intervals in one case, and open in another).

Empty intervals, i.e. intervals where 'lowerBound >= upperBound' should be avoided if possible. If you must use empty intervals, you need to provide implementations for all operations, as the default implementations do not necessarily work correctly. for example, the default implementation of inside returns True if the point is equal to the lowerBound of a left-closed interval even if it is larger than the upper bound.

Synopsis

Interval type

class Ord e => Interval i e | i -> e where #

Intervals with endpoints of type e. A minimal instance declaration for a closed interval needs only to define lowerBound and upperBound.

Minimal complete definition

lowerBound, upperBound

Methods

lowerBound :: i -> e #

lower bound

upperBound :: i -> e #

upper bound

leftClosed :: i -> Bool #

Does the interval include its lower bound? Default is True for all values, i.e. closed intervals.

rightClosed :: i -> Bool #

Does the interval include its upper bound bound? Default is True for all values, i.e. closed intervals.

before :: i -> i -> Bool #

Interval strictly before another? True if the upper bound of the first interval is below the lower bound of the second.

after :: i -> i -> Bool #

Interval strictly after another? Same as 'flip before'.

subsumes :: i -> i -> Bool #

Does the first interval completely contain the second?

overlaps :: i -> i -> Bool #

Do the two intervals overlap?

below :: e -> i -> Bool #

Is a point strictly less than lower bound?

above :: e -> i -> Bool #

Is a point strictly greater than upper bound?

inside :: e -> i -> Bool #

Does the interval contain a given point?

isEmpty :: i -> Bool #

Is the interval empty?

compareUpperBounds :: i -> i -> Ordering #

Instances

helper functions for declaring Eq and Ord instances

genericEquals :: Interval i e => i -> i -> Bool #

genericCompare :: Interval i e => i -> i -> Ordering #