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

Copyright (c) Christoph Breitkopf 2011 BSD-style chbreitkopf@gmail.com experimental portable Safe Haskell98

Data.IntervalMap.Interval

Description

A conservative implementation of Intervals, mostly for use as keys in a IntervalMap.

This should really be a typeclass, so you could have a tuple be an instance of Interval, but that is currently not possible in standard Haskell.

The contructor names of the half-open intervals seem somewhat clumsy, and I'm open to suggestions for better names.

Synopsis

Interval type

data Interval a Source #

Intervals with endpoints of type a.

Read and Show use mathematical notation with square brackets for closed and parens for open intervals. This is better for human readability, but is not a valid Haskell expression. Closed intervals look like a list, open intervals look like a tuple, and half-open intervals look like mismatched parens.

Constructors

 IntervalCO !a !a Including lower bound, excluding upper ClosedInterval !a !a Closed at both ends OpenInterval !a !a Open at both ends IntervalOC !a !a Excluding lower bound, including upper
Instances
 Source # Instance detailsDefined in Data.IntervalMap.Interval Methodsfmap :: (a -> b) -> Interval a -> Interval b #(<\$) :: a -> Interval b -> Interval a # Eq a => Eq (Interval a) Source # Instance detailsDefined in Data.IntervalMap.Interval Methods(==) :: Interval a -> Interval a -> Bool #(/=) :: Interval a -> Interval a -> Bool # Ord a => Ord (Interval a) Source # Instance detailsDefined in Data.IntervalMap.Interval Methodscompare :: Interval a -> Interval a -> Ordering #(<) :: Interval a -> Interval a -> Bool #(<=) :: Interval a -> Interval a -> Bool #(>) :: Interval a -> Interval a -> Bool #(>=) :: Interval a -> Interval a -> Bool #max :: Interval a -> Interval a -> Interval a #min :: Interval a -> Interval a -> Interval a # Read a => Read (Interval a) Source # Instance detailsDefined in Data.IntervalMap.Interval MethodsreadsPrec :: Int -> ReadS (Interval a) # Show a => Show (Interval a) Source # Instance detailsDefined in Data.IntervalMap.Interval MethodsshowsPrec :: Int -> Interval a -> ShowS #show :: Interval a -> String #showList :: [Interval a] -> ShowS # NFData a => NFData (Interval a) Source # Instance detailsDefined in Data.IntervalMap.Interval Methodsrnf :: Interval a -> () # Ord a => Interval (Interval a) a Source # Instance detailsDefined in Data.IntervalMap.Generic.Interval MethodslowerBound :: Interval a -> a Source #upperBound :: Interval a -> a Source #before :: Interval a -> Interval a -> Bool Source #after :: Interval a -> Interval a -> Bool Source #subsumes :: Interval a -> Interval a -> Bool Source #overlaps :: Interval a -> Interval a -> Bool Source #below :: a -> Interval a -> Bool Source #above :: a -> Interval a -> Bool Source #inside :: a -> Interval a -> Bool Source #

Query

lowerBound :: Interval a -> a Source #

Get the lower bound.

upperBound :: Interval a -> a Source #

Get the upper bound.

Does the interval include its lower bound?

Does the interval include its upper bound?

isEmpty :: Ord a => Interval a -> Bool Source #

Is the interval empty?

Interval operations

overlaps :: Ord a => Interval a -> Interval a -> Bool Source #

Do the two intervals overlap?

subsumes :: Ord a => Interval a -> Interval a -> Bool Source #

Does the first interval completely contain the second?

before :: Ord a => Interval a -> Interval a -> Bool Source #

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

after :: Ord a => Interval a -> Interval a -> Bool Source #

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

compareByUpper :: Ord a => Interval a -> Interval a -> Ordering Source #

Like compare, but considering the upper bound first.

combine :: Ord a => Interval a -> Interval a -> Maybe (Interval a) Source #

If the intervals overlap combine them into one.

Point operations

below :: Ord a => a -> Interval a -> Bool Source #

Is a point strictly less than lower bound?

inside :: Ord a => a -> Interval a -> Bool Source #

Does the interval contain a given point?

above :: Ord a => a -> Interval a -> Bool Source #

Is a point strictly greater than upper bound?