[insert lists into BagHeap
martin.hofmann@uni-bamberg.de**20091020100356] hunk ./src/Data/BagHeap.hs 11
-    singleton, insert, merge, 
+    singleton, insert,
+    singletonL, insertL, 
+    merge, 
hunk ./src/Data/BagHeap.hs 27
-import Data.List (foldl')
+-- import qualified Data.List as L (null)
+import Data.List (foldl', groupBy, partition,null)
+
hunk ./src/Data/BagHeap.hs 49
+-- | creates a singleton heap from a priority\/value-list pair. If 'lv' is 
+--   empty it, the empty heap is returned
+singletonL :: (Ord p) => p -> [v] -> BagHeap p v
+singletonL p vl 
+    | null vl   = empty 
+    | otherwise = BH $ H.singleton p (S.fromList vl) 
hunk ./src/Data/BagHeap.hs 60
+-- | 'insertL k lv h' inserts the list of values 'lv' with priority 'k' into 
+--   heap 'h'. If 'lv' is empty it, the empty heap is returned
+insertL :: (Ord p) => p -> [v] -> BagHeap p v -> BagHeap p v
+insertL  p vl 
+    | null vl   = id
+    | otherwise = flip merge (singletonL p vl)
+
hunk ./src/Data/BagHeap.hs 75
+----  | Returns the minimal priority\/value pair and the heap without it
+--getDelMinWhich :: (Ord p) => (v -> Bool) ->  BagHeap p v -> ((p,[v]),BagHeap p v)
+--getDelMinWhich f h = 
+--    let ((p,(vt,vf)),h') = ((id *** ((partition f).F.toList)) *** BH) . H.getDelMin $ unBH  h
+--    in ((p,vt), merge (singletonL p vf) h') 
+
hunk ./src/Data/BagHeap.hs 100
+
+fromAscList :: (Ord p) => [(p,v)] -> BagHeap p v
+fromAscList = (foldl' (flip $ uncurry insertL) empty) . groupAsc
+
+groupAsc :: (Eq p) => [(p,v)] -> [(p,[v])]
+groupAsc [] = []
+groupAsc (x:xs) = cons x (groupAsc xs)
+    where
+    cons (p,v) [] = [(p,[v])]
+    cons (p,v) xs@((p',vs):xss)
+        | p == p'   = ((p',v:vs):xss)
+        | otherwise = (p,[v]):xs 