fingertree-0.1.2.1: Generic finger-tree structure, with example instances

Copyright(c) Ross Paterson 2008
LicenseBSD-style
MaintainerR.Paterson@city.ac.uk
Stabilityexperimental
Portabilitynon-portable (MPTCs and functional dependencies)
Safe HaskellSafe
LanguageHaskell2010

Data.IntervalMap.FingerTree

Contents

Description

Interval maps implemented using the FingerTree type, following section 4.8 of

An amortized running time is given for each operation, with n referring to the size of the priority queue. These bounds hold even in a persistent (shared) setting.

Note: Many of these operations have the same names as similar operations on lists in the Prelude. The ambiguity may be resolved using either qualification or the hiding clause.

Synopsis

Intervals

data Interval v Source #

A closed interval. The lower bound should be less than or equal to the upper bound.

Constructors

Interval v v

Lower and upper bounds of the interval.

Instances

Eq v => Eq (Interval v) Source # 

Methods

(==) :: Interval v -> Interval v -> Bool #

(/=) :: Interval v -> Interval v -> Bool #

Ord v => Ord (Interval v) Source # 

Methods

compare :: Interval v -> Interval v -> Ordering #

(<) :: Interval v -> Interval v -> Bool #

(<=) :: Interval v -> Interval v -> Bool #

(>) :: Interval v -> Interval v -> Bool #

(>=) :: Interval v -> Interval v -> Bool #

max :: Interval v -> Interval v -> Interval v #

min :: Interval v -> Interval v -> Interval v #

Show v => Show (Interval v) Source # 

Methods

showsPrec :: Int -> Interval v -> ShowS #

show :: Interval v -> String #

showList :: [Interval v] -> ShowS #

low :: Interval v -> v Source #

Lower bound of the interval

high :: Interval v -> v Source #

Upper bound of the interval

point :: v -> Interval v Source #

An interval in which the lower and upper bounds are equal.

Interval maps

data IntervalMap v a Source #

Map of closed intervals, possibly with duplicates.

Instances

Functor (IntervalMap v) Source # 

Methods

fmap :: (a -> b) -> IntervalMap v a -> IntervalMap v b #

(<$) :: a -> IntervalMap v b -> IntervalMap v a #

Foldable (IntervalMap v) Source #

Values in lexicographical order of intervals.

Methods

fold :: Monoid m => IntervalMap v m -> m #

foldMap :: Monoid m => (a -> m) -> IntervalMap v a -> m #

foldr :: (a -> b -> b) -> b -> IntervalMap v a -> b #

foldr' :: (a -> b -> b) -> b -> IntervalMap v a -> b #

foldl :: (b -> a -> b) -> b -> IntervalMap v a -> b #

foldl' :: (b -> a -> b) -> b -> IntervalMap v a -> b #

foldr1 :: (a -> a -> a) -> IntervalMap v a -> a #

foldl1 :: (a -> a -> a) -> IntervalMap v a -> a #

toList :: IntervalMap v a -> [a] #

null :: IntervalMap v a -> Bool #

length :: IntervalMap v a -> Int #

elem :: Eq a => a -> IntervalMap v a -> Bool #

maximum :: Ord a => IntervalMap v a -> a #

minimum :: Ord a => IntervalMap v a -> a #

sum :: Num a => IntervalMap v a -> a #

product :: Num a => IntervalMap v a -> a #

Traversable (IntervalMap v) Source #

Traverse the intervals in lexicographical order.

Methods

traverse :: Applicative f => (a -> f b) -> IntervalMap v a -> f (IntervalMap v b) #

sequenceA :: Applicative f => IntervalMap v (f a) -> f (IntervalMap v a) #

mapM :: Monad m => (a -> m b) -> IntervalMap v a -> m (IntervalMap v b) #

sequence :: Monad m => IntervalMap v (m a) -> m (IntervalMap v a) #

(Eq v, Eq a) => Eq (IntervalMap v a) Source # 

Methods

(==) :: IntervalMap v a -> IntervalMap v a -> Bool #

(/=) :: IntervalMap v a -> IntervalMap v a -> Bool #

(Ord v, Ord a) => Ord (IntervalMap v a) Source #

Lexicographical ordering

Methods

compare :: IntervalMap v a -> IntervalMap v a -> Ordering #

(<) :: IntervalMap v a -> IntervalMap v a -> Bool #

(<=) :: IntervalMap v a -> IntervalMap v a -> Bool #

(>) :: IntervalMap v a -> IntervalMap v a -> Bool #

(>=) :: IntervalMap v a -> IntervalMap v a -> Bool #

max :: IntervalMap v a -> IntervalMap v a -> IntervalMap v a #

min :: IntervalMap v a -> IntervalMap v a -> IntervalMap v a #

(Show v, Show a) => Show (IntervalMap v a) Source # 

Methods

showsPrec :: Int -> IntervalMap v a -> ShowS #

show :: IntervalMap v a -> String #

showList :: [IntervalMap v a] -> ShowS #

Ord v => Semigroup (IntervalMap v a) Source #

union.

Methods

(<>) :: IntervalMap v a -> IntervalMap v a -> IntervalMap v a #

sconcat :: NonEmpty (IntervalMap v a) -> IntervalMap v a #

stimes :: Integral b => b -> IntervalMap v a -> IntervalMap v a #

Ord v => Monoid (IntervalMap v a) Source #

empty and union.

Methods

mempty :: IntervalMap v a #

mappend :: IntervalMap v a -> IntervalMap v a -> IntervalMap v a #

mconcat :: [IntervalMap v a] -> IntervalMap v a #

empty :: Ord v => IntervalMap v a Source #

O(1). The empty interval map.

singleton :: Ord v => Interval v -> a -> IntervalMap v a Source #

O(1). Interval map with a single entry.

insert :: Ord v => Interval v -> a -> IntervalMap v a -> IntervalMap v a Source #

O(log n). Insert an interval into a map. The map may contain duplicate intervals; the new entry will be inserted before any existing entries for the same interval.

union :: Ord v => IntervalMap v a -> IntervalMap v a -> IntervalMap v a Source #

O(m log (n/m)). Merge two interval maps. The map may contain duplicate intervals; entries with equal intervals are kept in the original order.

Searching

search :: Ord v => v -> IntervalMap v a -> [(Interval v, a)] Source #

O(k log (n/k)). All intervals that contain the given point, in lexicographical order.

intersections :: Ord v => Interval v -> IntervalMap v a -> [(Interval v, a)] Source #

O(k log (n/k)). All intervals that intersect with the given interval, in lexicographical order.

dominators :: Ord v => Interval v -> IntervalMap v a -> [(Interval v, a)] Source #

O(k log (n/k)). All intervals that contain the given interval, in lexicographical order.