Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Key a
- liftCmp :: (a -> a -> Ordering) -> Key a -> Key a -> Ordering
- newtype Elem a = Elem {
- getElem :: a
- newtype OrdSeq a = OrdSeq {
- _asFingerTree :: FingerTree (Key a) (Elem a)
- type Compare a = a -> a -> Ordering
- insertBy :: Compare a -> a -> OrdSeq a -> OrdSeq a
- insert :: Ord a => a -> OrdSeq a -> OrdSeq a
- deleteAllBy :: Compare a -> a -> OrdSeq a -> OrdSeq a
- splitBy :: Compare a -> a -> OrdSeq a -> (OrdSeq a, OrdSeq a, OrdSeq a)
- splitOn :: Ord b => (a -> b) -> b -> OrdSeq a -> (OrdSeq a, OrdSeq a, OrdSeq a)
- splitMonotonic :: (a -> Bool) -> OrdSeq a -> (OrdSeq a, OrdSeq a)
- deleteAll :: Ord a => a -> OrdSeq a -> OrdSeq a
- fromListBy :: Compare a -> [a] -> OrdSeq a
- fromListByOrd :: Ord a => [a] -> OrdSeq a
- fromAscList' :: [a] -> OrdSeq a
- lookupBy :: Compare a -> a -> OrdSeq a -> Maybe a
- memberBy :: Compare a -> a -> OrdSeq a -> Bool
- mapMonotonic :: (a -> b) -> OrdSeq a -> OrdSeq b
- viewl :: OrdSeq a -> ViewL OrdSeq a
- viewr :: OrdSeq a -> ViewR OrdSeq a
- minView :: OrdSeq a -> Maybe (a, OrdSeq a)
- lookupMin :: OrdSeq a -> Maybe a
- maxView :: OrdSeq a -> Maybe (a, OrdSeq a)
- lookupMax :: OrdSeq a -> Maybe a
Documentation
Instances
Functor Elem Source # | |
Foldable Elem Source # | |
Defined in Data.OrdSeq fold :: Monoid m => Elem m -> m # foldMap :: Monoid m => (a -> m) -> Elem a -> m # foldr :: (a -> b -> b) -> b -> Elem a -> b # foldr' :: (a -> b -> b) -> b -> Elem a -> b # foldl :: (b -> a -> b) -> b -> Elem a -> b # foldl' :: (b -> a -> b) -> b -> Elem a -> b # foldr1 :: (a -> a -> a) -> Elem a -> a # foldl1 :: (a -> a -> a) -> Elem a -> a # elem :: Eq a => a -> Elem a -> Bool # maximum :: Ord a => Elem a -> a # | |
Traversable Elem Source # | |
Eq a => Eq (Elem a) Source # | |
Ord a => Ord (Elem a) Source # | |
Show a => Show (Elem a) Source # | |
Measured (Key a) (Elem a) Source # | |
Defined in Data.OrdSeq |
OrdSeq | |
|
Instances
Foldable OrdSeq Source # | |
Defined in Data.OrdSeq fold :: Monoid m => OrdSeq m -> m # foldMap :: Monoid m => (a -> m) -> OrdSeq a -> m # foldr :: (a -> b -> b) -> b -> OrdSeq a -> b # foldr' :: (a -> b -> b) -> b -> OrdSeq a -> b # foldl :: (b -> a -> b) -> b -> OrdSeq a -> b # foldl' :: (b -> a -> b) -> b -> OrdSeq a -> b # foldr1 :: (a -> a -> a) -> OrdSeq a -> a # foldl1 :: (a -> a -> a) -> OrdSeq a -> a # elem :: Eq a => a -> OrdSeq a -> Bool # maximum :: Ord a => OrdSeq a -> a # minimum :: Ord a => OrdSeq a -> a # | |
Eq a => Eq (OrdSeq a) Source # | |
Show a => Show (OrdSeq a) Source # | |
Semigroup (OrdSeq a) Source # | |
Monoid (OrdSeq a) Source # | |
(Arbitrary a, Ord a) => Arbitrary (OrdSeq a) Source # | |
insertBy :: Compare a -> a -> OrdSeq a -> OrdSeq a Source #
Insert into a monotone OrdSeq.
pre: the comparator maintains monotonicity
\(O(\log n)\)
splitOn :: Ord b => (a -> b) -> b -> OrdSeq a -> (OrdSeq a, OrdSeq a, OrdSeq a) Source #
Given a monotonic function f that maps a to b, split the sequence s depending on the b values. I.e. the result (l,m,r) is such that * all (< x) . fmap f $ l * all (== x) . fmap f $ m * all (> x) . fmap f $ r
>>>
splitOn id 3 $ fromAscList' [1..5]
(OrdSeq {_asFingerTree = fromList [Elem 1,Elem 2]},OrdSeq {_asFingerTree = fromList [Elem 3]},OrdSeq {_asFingerTree = fromList [Elem 4,Elem 5]})>>>
splitOn fst 2 $ fromAscList' [(0,"-"),(1,"A"),(2,"B"),(2,"C"),(3,"D"),(4,"E")]
(OrdSeq {_asFingerTree = fromList [Elem (0,"-"),Elem (1,"A")]},OrdSeq {_asFingerTree = fromList [Elem (2,"B"),Elem (2,"C")]},OrdSeq {_asFingerTree = fromList [Elem (3,"D"),Elem (4,"E")]})
\(O(\log n)\)
splitMonotonic :: (a -> Bool) -> OrdSeq a -> (OrdSeq a, OrdSeq a) Source #
Given a monotonic predicate p, splits the sequence s into two sequences (as,bs) such that all (not p) as and all p bs
\(O(\log n)\)
fromListBy :: Compare a -> [a] -> OrdSeq a Source #
inserts all eleements in order \(O(n\log n)\)
fromListByOrd :: Ord a => [a] -> OrdSeq a Source #
inserts all eleements in order \(O(n\log n)\)
fromAscList' :: [a] -> OrdSeq a Source #
O(n)
mapMonotonic :: (a -> b) -> OrdSeq a -> OrdSeq b Source #
Fmap, assumes the order does not change O(n)