module Data.IntervalMap.Lazy (
I.Interval(..)
, IntervalMap
, (!), (\\)
, null
, size
, member
, notMember
, lookup
, findWithDefault
, lookupLT
, lookupGT
, lookupLE
, lookupGE
, containing
, intersecting
, within
, empty
, singleton
, insert
, insertWith
, insertWithKey
, insertLookupWithKey
, delete
, adjust
, adjustWithKey
, update
, updateWithKey
, updateLookupWithKey
, alter
, union
, unionWith
, unionWithKey
, unions
, unionsWith
, difference
, differenceWith
, differenceWithKey
, intersection
, intersectionWith
, intersectionWithKey
, map
, mapWithKey
, mapAccum
, mapAccumWithKey
, mapAccumRWithKey
, mapKeys
, mapKeysWith
, mapKeysMonotonic
, foldr, foldl
, foldrWithKey, foldlWithKey
, flattenWith
, elems
, keys
, keysSet
, assocs
, toList
, fromList
, fromListWith
, fromListWithKey
, toAscList
, toDescList
, fromAscList
, fromAscListWith
, fromAscListWithKey
, fromDistinctAscList
, filter
, filterWithKey
, partition
, partitionWithKey
, mapMaybe
, mapMaybeWithKey
, mapEither
, mapEitherWithKey
, split
, splitLookup
, splitAt
, splitIntersecting
, isSubmapOf, isSubmapOfBy
, isProperSubmapOf, isProperSubmapOfBy
, findMin
, findMax
, findLast
, lookupMin
, lookupMax
, lookupLast
, deleteMin
, deleteMax
, deleteFindMin
, deleteFindMax
, updateMin
, updateMax
, updateMinWithKey
, updateMaxWithKey
, minView
, maxView
, minViewWithKey
, maxViewWithKey
, valid
, height, maxHeight, showStats
) where
import Prelude hiding (filter, foldl, foldr, lookup, map, null, splitAt)
import Data.IntervalMap.Interval as I
import Data.IntervalMap.Generic.Lazy hiding (IntervalMap, flattenWith)
import qualified Data.IntervalMap.Generic.Lazy as M
type IntervalMap k v = M.IntervalMap (I.Interval k) v
flattenWith :: (Ord k) => (v -> v -> v) -> IntervalMap k v -> IntervalMap k v
flattenWith :: forall k v.
Ord k =>
(v -> v -> v) -> IntervalMap k v -> IntervalMap k v
flattenWith v -> v -> v
f IntervalMap k v
m = ((Interval k, v) -> (Interval k, v) -> Maybe (Interval k, v))
-> IntervalMap k v -> IntervalMap k v
forall k e v.
Interval k e =>
((k, v) -> (k, v) -> Maybe (k, v))
-> IntervalMap k v -> IntervalMap k v
M.flattenWithMonotonic (Interval k, v) -> (Interval k, v) -> Maybe (Interval k, v)
forall {a}.
Ord a =>
(Interval a, v) -> (Interval a, v) -> Maybe (Interval a, v)
f' IntervalMap k v
m
where
f' :: (Interval a, v) -> (Interval a, v) -> Maybe (Interval a, v)
f' (Interval a
k1,v
v1) (Interval a
k2,v
v2) = case Interval a -> Interval a -> Maybe (Interval a)
forall a. Ord a => Interval a -> Interval a -> Maybe (Interval a)
combine Interval a
k1 Interval a
k2 of
Maybe (Interval a)
Nothing -> Maybe (Interval a, v)
forall a. Maybe a
Nothing
Just Interval a
k' -> (Interval a, v) -> Maybe (Interval a, v)
forall a. a -> Maybe a
Just (Interval a
k', v -> v -> v
f v
v1 v
v2)