hw-fingertree-strict-0.1.1.1: Generic strict finger-tree structure

Copyright(c) Arbor Networks 2017
LicenseBSD-style
Maintainermayhem@arbor.net
Stabilityexperimental
Portabilitynon-portable (MPTCs and functional dependencies)
Safe HaskellSafe
LanguageHaskell2010

HaskellWorks.Data.SegmentSet.Strict

Contents

Description

SegmentSet provides an efficient implementation of a set of segments (a.k.a intervals). Segments in the set are non-overlapping. Adjacent segments are merged (i.e. (a .. b), (b + 1 .. c) -> (a .. c)).

Segment sets are 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 set. 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

Segments

data Segment k Source #

A closed segment. The lower bound should be less than or equal to the higher bound.

Constructors

Segment 

Fields

Instances

Monoid k => Measured k (Segment k) Source # 

Methods

measure :: Segment k -> k Source #

Eq k => Eq (Segment k) Source # 

Methods

(==) :: Segment k -> Segment k -> Bool #

(/=) :: Segment k -> Segment k -> Bool #

Ord k => Ord (Segment k) Source # 

Methods

compare :: Segment k -> Segment k -> Ordering #

(<) :: Segment k -> Segment k -> Bool #

(<=) :: Segment k -> Segment k -> Bool #

(>) :: Segment k -> Segment k -> Bool #

(>=) :: Segment k -> Segment k -> Bool #

max :: Segment k -> Segment k -> Segment k #

min :: Segment k -> Segment k -> Segment k #

Show k => Show (Segment k) Source # 

Methods

showsPrec :: Int -> Segment k -> ShowS #

show :: Segment k -> String #

showList :: [Segment k] -> ShowS #

Generic (Segment k) Source # 

Associated Types

type Rep (Segment k) :: * -> * #

Methods

from :: Segment k -> Rep (Segment k) x #

to :: Rep (Segment k) x -> Segment k #

NFData k => NFData (Segment k) Source # 

Methods

rnf :: Segment k -> () #

type Rep (Segment k) Source # 
type Rep (Segment k) = D1 * (MetaData "Segment" "HaskellWorks.Data.Segment.Strict" "hw-fingertree-strict-0.1.1.1-1UsuYkohZPGJ8bjSrBSs55" False) (C1 * (MetaCons "Segment" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "low") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * k)) (S1 * (MetaSel (Just Symbol "high") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * k))))

point :: k -> Segment k Source #

A segment in which the lower and upper bounds are equal.

Segment maps

newtype SegmentSet k Source #

Constructors

SegmentSet (OrderedMap (Max k) (Segment k)) 

Instances

Show k => Show (SegmentSet k) Source # 
Generic (SegmentSet k) Source # 

Associated Types

type Rep (SegmentSet k) :: * -> * #

Methods

from :: SegmentSet k -> Rep (SegmentSet k) x #

to :: Rep (SegmentSet k) x -> SegmentSet k #

NFData k => NFData (SegmentSet k) Source # 

Methods

rnf :: SegmentSet k -> () #

type Rep (SegmentSet k) Source # 
type Rep (SegmentSet k) = D1 * (MetaData "SegmentSet" "HaskellWorks.Data.SegmentSet.Strict" "hw-fingertree-strict-0.1.1.1-1UsuYkohZPGJ8bjSrBSs55" True) (C1 * (MetaCons "SegmentSet" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (OrderedMap (Max k) (Segment k)))))

newtype OrderedMap k a Source #

Map of closed segments, possibly with duplicates. The Foldable and Traversable instances process the segments in lexicographical order.

Constructors

OrderedMap (FingerTree k (Item k a)) 

Instances

Functor (OrderedMap k) Source # 

Methods

fmap :: (a -> b) -> OrderedMap k a -> OrderedMap k b #

(<$) :: a -> OrderedMap k b -> OrderedMap k a #

Foldable (OrderedMap k) Source # 

Methods

fold :: Monoid m => OrderedMap k m -> m #

foldMap :: Monoid m => (a -> m) -> OrderedMap k a -> m #

foldr :: (a -> b -> b) -> b -> OrderedMap k a -> b #

foldr' :: (a -> b -> b) -> b -> OrderedMap k a -> b #

foldl :: (b -> a -> b) -> b -> OrderedMap k a -> b #

foldl' :: (b -> a -> b) -> b -> OrderedMap k a -> b #

foldr1 :: (a -> a -> a) -> OrderedMap k a -> a #

foldl1 :: (a -> a -> a) -> OrderedMap k a -> a #

toList :: OrderedMap k a -> [a] #

null :: OrderedMap k a -> Bool #

length :: OrderedMap k a -> Int #

elem :: Eq a => a -> OrderedMap k a -> Bool #

maximum :: Ord a => OrderedMap k a -> a #

minimum :: Ord a => OrderedMap k a -> a #

sum :: Num a => OrderedMap k a -> a #

product :: Num a => OrderedMap k a -> a #

Traversable (OrderedMap k) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> OrderedMap k a -> f (OrderedMap k b) #

sequenceA :: Applicative f => OrderedMap k (f a) -> f (OrderedMap k a) #

mapM :: Monad m => (a -> m b) -> OrderedMap k a -> m (OrderedMap k b) #

sequence :: Monad m => OrderedMap k (m a) -> m (OrderedMap k a) #

(Show a, Show k) => Show (OrderedMap k a) Source # 

Methods

showsPrec :: Int -> OrderedMap k a -> ShowS #

show :: OrderedMap k a -> String #

showList :: [OrderedMap k a] -> ShowS #

Generic (OrderedMap k a) Source # 

Associated Types

type Rep (OrderedMap k a) :: * -> * #

Methods

from :: OrderedMap k a -> Rep (OrderedMap k a) x #

to :: Rep (OrderedMap k a) x -> OrderedMap k a #

(NFData a, NFData k) => NFData (OrderedMap k a) Source # 

Methods

rnf :: OrderedMap k a -> () #

type Rep (OrderedMap k a) Source # 
type Rep (OrderedMap k a) = D1 * (MetaData "OrderedMap" "HaskellWorks.Data.SegmentSet.Strict" "hw-fingertree-strict-0.1.1.1-1UsuYkohZPGJ8bjSrBSs55" True) (C1 * (MetaCons "OrderedMap" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (FingerTree k (Item k a)))))

delete :: forall k a. (Bounded k, Ord k, Enum k, Show k) => Segment k -> SegmentSet k -> SegmentSet k Source #

O(log(n)). Remove a segment from the set. Alias of update.

empty :: SegmentSet k Source #

O(1). The empty segment set.

fromList :: (Ord v, Enum v, Bounded v, Show v) => [Segment v] -> SegmentSet v Source #

insert :: forall k a. (Bounded k, Ord k, Enum k, Show k) => Segment k -> SegmentSet k -> SegmentSet k Source #

O(log(n)). Insert a segment into the set. Alias of update.

singleton :: Segment k -> SegmentSet k Source #

O(1). Segment set with a single entry.

update :: forall k a. (Ord k, Enum k, Bounded k, Show k) => Segment k -> Bool -> SegmentSet k -> SegmentSet k Source #

Update a segment set. Prefer insert or delete in most cases.

data Item k a Source #

Constructors

Item !k !a 

Instances

Monoid k => Measured k (Item k a) Source # 

Methods

measure :: Item k a -> k Source #

Functor (Item k) Source # 

Methods

fmap :: (a -> b) -> Item k a -> Item k b #

(<$) :: a -> Item k b -> Item k a #

Foldable (Item k) Source # 

Methods

fold :: Monoid m => Item k m -> m #

foldMap :: Monoid m => (a -> m) -> Item k a -> m #

foldr :: (a -> b -> b) -> b -> Item k a -> b #

foldr' :: (a -> b -> b) -> b -> Item k a -> b #

foldl :: (b -> a -> b) -> b -> Item k a -> b #

foldl' :: (b -> a -> b) -> b -> Item k a -> b #

foldr1 :: (a -> a -> a) -> Item k a -> a #

foldl1 :: (a -> a -> a) -> Item k a -> a #

toList :: Item k a -> [a] #

null :: Item k a -> Bool #

length :: Item k a -> Int #

elem :: Eq a => a -> Item k a -> Bool #

maximum :: Ord a => Item k a -> a #

minimum :: Ord a => Item k a -> a #

sum :: Num a => Item k a -> a #

product :: Num a => Item k a -> a #

Traversable (Item k) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Item k a -> f (Item k b) #

sequenceA :: Applicative f => Item k (f a) -> f (Item k a) #

mapM :: Monad m => (a -> m b) -> Item k a -> m (Item k b) #

sequence :: Monad m => Item k (m a) -> m (Item k a) #

(Eq a, Eq k) => Eq (Item k a) Source # 

Methods

(==) :: Item k a -> Item k a -> Bool #

(/=) :: Item k a -> Item k a -> Bool #

(Show a, Show k) => Show (Item k a) Source # 

Methods

showsPrec :: Int -> Item k a -> ShowS #

show :: Item k a -> String #

showList :: [Item k a] -> ShowS #

Generic (Item k a) Source # 

Associated Types

type Rep (Item k a) :: * -> * #

Methods

from :: Item k a -> Rep (Item k a) x #

to :: Rep (Item k a) x -> Item k a #

(NFData a, NFData k) => NFData (Item k a) Source # 

Methods

rnf :: Item k a -> () #

type Rep (Item k a) Source # 
type Rep (Item k a) = D1 * (MetaData "Item" "HaskellWorks.Data.Item.Strict" "hw-fingertree-strict-0.1.1.1-1UsuYkohZPGJ8bjSrBSs55" False) (C1 * (MetaCons "Item" PrefixI False) ((:*:) * (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * k)) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * a))))

cappedL :: (Enum k, Ord k, Bounded k, Show k) => k -> FingerTree (Max k) (Item (Max k) (Segment k)) -> (FingerTree (Max k) (Item (Max k) (Segment k)), FingerTree (Max k) (Item (Max k) (Segment k))) Source #

cappedM :: (Enum k, Ord k, Bounded k, Show k) => k -> FingerTree (Max k) (Item (Max k) (Segment k)) -> FingerTree (Max k) (Item (Max k) (Segment k)) Source #