Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Synopsis
- data OMap k v
- empty :: OMap k v
- singleton :: (k, v) -> OMap k v
- (<|) :: Ord k => (,) k v -> OMap k v -> OMap k v
- (|<) :: Ord k => (,) k v -> OMap k v -> OMap k v
- (>|) :: Ord k => OMap k v -> (,) k v -> OMap k v
- (|>) :: Ord k => OMap k v -> (,) k v -> OMap k v
- (<>|) :: Ord k => OMap k v -> OMap k v -> OMap k v
- (|<>) :: Ord k => OMap k v -> OMap k v -> OMap k v
- unionWithL :: Ord k => (k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v
- unionWithR :: Ord k => (k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v
- newtype Bias (dir :: IndexPreference) a = Bias {
- unbiased :: a
- type L = L
- type R = R
- delete :: Ord k => k -> OMap k v -> OMap k v
- filter :: Ord k => (k -> v -> Bool) -> OMap k v -> OMap k v
- (\\) :: Ord k => OMap k v -> OMap k v' -> OMap k v
- (|/\) :: Ord k => OMap k v -> OMap k v' -> OMap k v
- (/\|) :: Ord k => OMap k v -> OMap k v' -> OMap k v
- intersectionWith :: Ord k => (k -> v -> v' -> v'') -> OMap k v -> OMap k v' -> OMap k v''
- null :: OMap k v -> Bool
- size :: OMap k v -> Int
- member :: Ord k => k -> OMap k v -> Bool
- notMember :: Ord k => k -> OMap k v -> Bool
- lookup :: Ord k => k -> OMap k v -> Maybe v
- type Index = Int
- findIndex :: Ord k => k -> OMap k v -> Maybe Index
- elemAt :: OMap k v -> Index -> Maybe (k, v)
- fromList :: Ord k => [(k, v)] -> OMap k v
- assocs :: OMap k v -> [(k, v)]
- toAscList :: OMap k v -> [(k, v)]
Documentation
Instances
Functor (OMap k) Source # | |
Foldable (OMap k) Source # | Values are produced in insertion order, not key order. |
Defined in Data.Map.Ordered fold :: Monoid m => OMap k m -> m # foldMap :: Monoid m => (a -> m) -> OMap k a -> m # foldr :: (a -> b -> b) -> b -> OMap k a -> b # foldr' :: (a -> b -> b) -> b -> OMap k a -> b # foldl :: (b -> a -> b) -> b -> OMap k a -> b # foldl' :: (b -> a -> b) -> b -> OMap k a -> b # foldr1 :: (a -> a -> a) -> OMap k a -> a # foldl1 :: (a -> a -> a) -> OMap k a -> a # elem :: Eq a => a -> OMap k a -> Bool # maximum :: Ord a => OMap k a -> a # minimum :: Ord a => OMap k a -> a # | |
Ord k => Traversable (OMap k) Source # | Values are traversed in insertion order, not key order. O(n*log(n)) where n is the size of the map. |
(Eq k, Eq v) => Eq (OMap k v) Source # | |
(Data k, Data a, Ord k) => Data (OMap k a) Source # | |
Defined in Data.Map.Ordered gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OMap k a -> c (OMap k a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (OMap k a) # toConstr :: OMap k a -> Constr # dataTypeOf :: OMap k a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (OMap k a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OMap k a)) # gmapT :: (forall b. Data b => b -> b) -> OMap k a -> OMap k a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OMap k a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OMap k a -> r # gmapQ :: (forall d. Data d => d -> u) -> OMap k a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> OMap k a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> OMap k a -> m (OMap k a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OMap k a -> m (OMap k a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OMap k a -> m (OMap k a) # | |
(Ord k, Ord v) => Ord (OMap k v) Source # | |
Defined in Data.Map.Ordered | |
(Ord k, Read k, Read v) => Read (OMap k v) Source # | |
(Show k, Show v) => Show (OMap k v) Source # | |
(Ord k, Semigroup v) => Semigroup (Bias R (OMap k v)) Source # | |
(Ord k, Semigroup v) => Semigroup (Bias L (OMap k v)) Source # | |
(Ord k, Monoid v) => Monoid (Bias R (OMap k v)) Source # | Empty maps and map union. When combining two sets that share elements, the
indices of the right argument are preferred, and the values are combined
with See the asymptotics of |
(Ord k, Monoid v) => Monoid (Bias L (OMap k v)) Source # | Empty maps and map union. When combining two sets that share elements, the
indices of the left argument are preferred, and the values are combined with
See the asymptotics of |
Trivial maps
Insertion
Conventions:
- The open side of an angle bracket points to an
OMap
- The pipe appears on the side whose indices take precedence if both sides contain the same key
- The left argument's indices are lower than the right argument's indices
- If both sides contain the same key, the tuple's value wins
(<>|) :: Ord k => OMap k v -> OMap k v -> OMap k v infixr 6 Source #
When a key occurs in both maps, prefer the value from the first map.
See asymptotics of unionWithR
.
(|<>) :: Ord k => OMap k v -> OMap k v -> OMap k v infixr 6 Source #
When a key occurs in both maps, prefer the value from the first map.
See asymptotics of unionWithL
.
unionWithL :: Ord k => (k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v Source #
Take the union. The first OMap
's argument's indices are lower than the
second. If a key appears in both maps, the first argument's index takes
precedence, and the supplied function is used to combine the values.
O(r*log(r)) where r is the size of the result
unionWithR :: Ord k => (k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v Source #
Take the union. The first OMap
's argument's indices are lower than the
second. If a key appears in both maps, the second argument's index takes
precedence, and the supplied function is used to combine the values.
O(r*log(r)) where r is the size of the result
newtype Bias (dir :: IndexPreference) a Source #
A newtype to hand a Monoid
instance on. The phantom first parameter
tells whether mappend
will prefer the indices of its first or second
argument if there are shared elements in both.
Instances
(Ord k, Semigroup v) => Semigroup (Bias R (OMap k v)) Source # | |
Ord a => Semigroup (Bias R (OSet a)) Source # | |
(Ord k, Semigroup v) => Semigroup (Bias L (OMap k v)) Source # | |
Ord a => Semigroup (Bias L (OSet a)) Source # | |
(Ord k, Monoid v) => Monoid (Bias R (OMap k v)) Source # | Empty maps and map union. When combining two sets that share elements, the
indices of the right argument are preferred, and the values are combined
with See the asymptotics of |
Ord a => Monoid (Bias R (OSet a)) Source # | Empty sets and set union. When combining two sets that share elements, the indices of the right argument are preferred. See the asymptotics of ( |
(Ord k, Monoid v) => Monoid (Bias L (OMap k v)) Source # | Empty maps and map union. When combining two sets that share elements, the
indices of the left argument are preferred, and the values are combined with
See the asymptotics of |
Ord a => Monoid (Bias L (OSet a)) Source # | Empty sets and set union. When combining two sets that share elements, the indices of the left argument are preferred. See the asymptotics of ( |
Deletion
filter :: Ord k => (k -> v -> Bool) -> OMap k v -> OMap k v Source #
filter f m
contains exactly the key-value pairs of m
that satisfy f
,
without changing the order they appear
(\\) :: Ord k => OMap k v -> OMap k v' -> OMap k v Source #
m \\ n
deletes all the keys that exist in n
from m
O(m*log(n)) where m is the size of the smaller map and n is the size of the larger map.
(|/\) :: Ord k => OMap k v -> OMap k v' -> OMap k v Source #
Intersection. (The /\
is intended to look a bit like the standard
mathematical notation for set intersection.)
See asymptotics of intersectionWith
.
(/\|) :: Ord k => OMap k v -> OMap k v' -> OMap k v Source #
Intersection. (The /\
is intended to look a bit like the standard
mathematical notation for set intersection.)
See asymptotics of intersectionWith
.
intersectionWith :: Ord k => (k -> v -> v' -> v'') -> OMap k v -> OMap k v' -> OMap k v'' Source #
Take the intersection. The first OMap
's argument's indices are used for
the result.
O(m*log(n/(m+1)) + r*log(r)) where m is the size of the smaller map, n is the size of the larger map, and r is the size of the result.
Query
Indexing
A 0-based index, much like the indices used by lists' !!
operation. All
indices are with respect to insertion order.