ordered-containers-0.1.1: Set- and Map-like types that remember the order elements were inserted

Safe HaskellSafe
LanguageHaskell98

Data.Map.Ordered

Contents

Description

An OMap behaves much like a Map, with all the same asymptotics, but also remembers the order that keys were inserted.

Synopsis

Documentation

data OMap k v Source #

Instances
Foldable (OMap k) Source #

Values are produced in insertion order, not key order.

Instance details

Defined in Data.Map.Ordered

Methods

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 #

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

null :: OMap k a -> Bool #

length :: OMap k a -> Int #

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

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

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

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

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

(Eq k, Eq v) => Eq (OMap k v) Source # 
Instance details

Defined in Data.Map.Ordered

Methods

(==) :: OMap k v -> OMap k v -> Bool #

(/=) :: OMap k v -> OMap k v -> Bool #

(Ord k, Ord v) => Ord (OMap k v) Source # 
Instance details

Defined in Data.Map.Ordered

Methods

compare :: OMap k v -> OMap k v -> Ordering #

(<) :: OMap k v -> OMap k v -> Bool #

(<=) :: OMap k v -> OMap k v -> Bool #

(>) :: OMap k v -> OMap k v -> Bool #

(>=) :: OMap k v -> OMap k v -> Bool #

max :: OMap k v -> OMap k v -> OMap k v #

min :: OMap k v -> OMap k v -> OMap k v #

(Ord k, Read k, Read v) => Read (OMap k v) Source # 
Instance details

Defined in Data.Map.Ordered

Methods

readsPrec :: Int -> ReadS (OMap k v) #

readList :: ReadS [OMap k v] #

readPrec :: ReadPrec (OMap k v) #

readListPrec :: ReadPrec [OMap k v] #

(Show k, Show v) => Show (OMap k v) Source # 
Instance details

Defined in Data.Map.Ordered

Methods

showsPrec :: Int -> OMap k v -> ShowS #

show :: OMap k v -> String #

showList :: [OMap k v] -> ShowS #

Trivial maps

singleton :: (k, v) -> OMap k v Source #

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 => (,) k v -> OMap k v -> OMap k v infixr 5 Source #

(|<) :: Ord k => (,) k v -> OMap k v -> OMap k v infixr 5 Source #

(>|) :: Ord k => OMap k v -> (,) k v -> OMap k v infixl 5 Source #

(|>) :: Ord k => OMap k v -> (,) k v -> OMap k v infixl 5 Source #

Deletion

delete :: Ord k => k -> OMap k v -> OMap k v Source #

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

Query

null :: OMap k v -> Bool Source #

size :: OMap k v -> Int Source #

member :: Ord k => k -> OMap k v -> Bool Source #

notMember :: Ord k => k -> OMap k v -> Bool Source #

lookup :: Ord k => k -> OMap k v -> Maybe v Source #

Indexing

type Index = Int Source #

A 0-based index, much like the indices used by lists' !! operation. All indices are with respect to insertion order.

findIndex :: Ord k => k -> OMap k v -> Maybe Index Source #

elemAt :: OMap k v -> Index -> Maybe (k, v) Source #

List conversions

fromList :: Ord k => [(k, v)] -> OMap k v Source #

If a key appears multiple times, the first occurrence is used for ordering and the last occurrence is used for its value. The library author welcomes comments on whether this default is sane.

assocs :: OMap k v -> [(k, v)] Source #

Return key-value pairs in the order they were inserted.

toAscList :: OMap k v -> [(k, v)] Source #

Return key-value pairs in order of increasing key.