"Committed_by_peb"

This commit is contained in:
peb
2005-02-18 18:21:06 +00:00
parent 1c4f025320
commit 9568d7a844
149 changed files with 1518 additions and 1160 deletions

View File

@@ -5,24 +5,23 @@
-- Stability : Stable
-- Portability : Haskell 98
--
-- > CVS $Date $
-- > CVS $Author $
-- > CVS $Revision $
-- > CVS $Date: 2005/02/18 19:21:15 $
-- > CVS $Author: peb $
-- > CVS $Revision: 1.5 $
--
-- (Description of the module)
-----------------------------------------------------------------------------
module Map
(
module Map (
Map,
empty,
isEmpty,
(!), -- lookup operator.
(!+), -- lookupMany operator.
(|->), -- insert operator.
(|->+), -- insertMany operator.
(<+>), -- union operator.
flatten --
(!),
(!+),
(|->),
(|->+),
(<+>),
flatten
) where
import RedBlack
@@ -38,20 +37,25 @@ infixl 4 <+>
empty :: Map key el
empty = emptyTree
-- | lookup operator.
(!) :: Ord key => Map key el -> key -> Maybe el
fm ! e = lookupTree e fm
-- | lookupMany operator.
(!+) :: Ord key => Map key el -> [key] -> [Maybe el]
fm !+ [] = []
fm !+ (e:es) = (lookupTree e fm): (fm !+ es)
-- | insert operator.
(|->) :: Ord key => (key,el) -> Map key el -> Map key el
(x,y) |-> fm = insertTree (x,y) fm
-- | insertMany operator.
(|->+) :: Ord key => [(key,el)] -> Map key el -> Map key el
[] |->+ fm = fm
((x,y):xs) |->+ fm = xs |->+ (insertTree (x,y) fm)
-- | union operator.
(<+>) :: Ord key => Map key el -> Map key el -> Map key el
(<+>) fm1 fm2 = xs |->+ fm2
where xs = flatten fm1