5784N/ADescription : ordered maps (these keep insertion order)
5784N/ACopyright : (c) Klaus L�ttich and Uni Bremen 2005
5784N/AMaintainer : luettich@tzi.de
5784N/AOrdered maps (these keep insertion order)
5784N/Aordered maps keep the ordering if converted from a list and of all
5784N/Ainsert operations which are implemented; toList uses the
5784N/Ainsertion\/conversion order for the creation of the new list
5784N/A , insert,insertWith,insertWithKey
5784N/A , partition, partitionWithKey
5784N/Aimport Prelude hiding (lookup,map,filter,foldr,foldl,null)
5784N/Ainfix 9 \\ -- add a comment for cpp
5784N/A(\\) :: Ord k => OMap k a -> OMap k b -> OMap k a
5784N/Adata ElemWOrd a = EWOrd { order :: Int
5784N/Ainstance Eq a => Eq (ElemWOrd a) where
5784N/Ainstance Ord a => Ord (ElemWOrd a) where
5784N/A compare x y = ele x `compare` ele y
5784N/Alookup :: (Monad m,Functor m,Ord k) => k -> OMap k a -> m a
5784N/Ainsert :: Ord k => k -> a -> OMap k a -> OMap k a
5784N/AinsertWith :: Ord k => (a -> a -> a) -> k -> a -> OMap k a -> OMap k a
5784N/AinsertWith f k e m = insertWithKey (\ _k x y -> f x y) k e m
5784N/AinsertWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> OMap k a -> OMap k a
5784N/Adelete :: Ord k => k -> OMap k a -> OMap k a
5784N/A Int -- ^ order of removed element
5784N/A | order e == dOrder = error "Something strange happened"
5784N/A | order e > dOrder = e { order = order e - 1}
5784N/A | otherwise = error "Never happens"
5784N/Aupdate :: Ord k => (a -> Maybe a) -> k -> OMap k a -> OMap k a
5784N/Aupdate f k m = updateWithKey (\ _k x -> f x) k m
5784N/AupdateWithKey :: Ord k => (k -> a -> Maybe a) -> k -> OMap k a -> OMap k a
5784N/A Just x -> Just (e {ele = x})) k m1
5784N/Afilter :: Ord k => (a -> Bool) -> OMap k a -> OMap k a
5784N/Afilter p = filterWithKey (\ _k x -> p x)
5784N/AfilterWithKey :: Ord k => (k -> a -> Bool) -> OMap k a -> OMap k a
5784N/Adifference :: Ord k => OMap k a -> OMap k b -> OMap k a
5784N/Amap :: Ord k => (a -> b) -> OMap k a -> OMap k b
5784N/Amap f = mapWithKey (\ _k x -> f x)
5784N/AmapWithKey :: (k -> a -> b) -> OMap k a -> OMap k b
5784N/Apartition :: Ord k => (a -> Bool) -> OMap k a -> (OMap k a,OMap k a)
5784N/Apartition p = partitionWithKey (\ _k a -> p a)
5784N/ApartitionWithKey :: Ord k => (k -> a -> Bool) -> OMap k a
5784N/A (x,y) -> (updOrder x,updOrder y)
5784N/A where updOrder = fromList . toList
5784N/AfromList :: Ord k => [(k,a)] -> OMap k a
5784N/A where ins m (k,e) = insert k e m
5784N/AtoList :: Ord k => OMap k a -> [(k,a)]
5784N/A where comp (_,x) (_,y) = compare (order x) (order y)
5784N/Akeys :: Ord k => OMap k a -> [k]