IntervalMap-0.6.0.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 Source #

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 Source #

lower bound

upperBound :: i -> e Source #

upper bound

leftClosed :: i -> Bool Source #

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

rightClosed :: i -> Bool Source #

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

before :: i -> i -> Bool Source #

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 Source #

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

subsumes :: i -> i -> Bool Source #

Does the first interval completely contain the second?

overlaps :: i -> i -> Bool Source #

Do the two intervals overlap?

below :: e -> i -> Bool Source #

Is a point strictly less than lower bound?

above :: e -> i -> Bool Source #

Is a point strictly greater than upper bound?

inside :: e -> i -> Bool Source #

Does the interval contain a given point?

isEmpty :: i -> Bool Source #

Is the interval empty?

compareUpperBounds :: i -> i -> Ordering Source #

helper functions for declaring Eq and Ord instances

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