From e6497426df0a84ab458e7c2a1d1f839b4e02d8f3 Mon Sep 17 00:00:00 2001
From: Liyang HU <git@liyang.hu>
Date: Tue, 7 Jun 2011 15:47:39 +0900
Subject: [PATCH 3/5] Added IntMap.differenceKeysSet for removing an IntSet of keys

Data/IntMap.hs  29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions()
diff git a/Data/IntMap.hs b/Data/IntMap.hs
index fe0b353..dc32a7a 100644
a

b

module Data.IntMap ( 
97  97  , difference 
98  98  , differenceWith 
99  99  , differenceWithKey 
 100  , differenceKeysSet 
100  101  
101  102   ** Intersection 
102  103  , intersection 
… 
… 
module Data.IntMap ( 
176  177  import Prelude hiding (lookup,map,filter,foldr,foldl,null) 
177  178  import Data.Bits 
178  179  import qualified Data.IntSet as IntSet 
 180  import qualified Data.IntSet.Internal as IntSet 
179  181  import Data.Monoid (Monoid(..)) 
180  182  import Data.Maybe (fromMaybe) 
181  183  import Data.Typeable 
… 
… 
difference Nil _ = Nil 
744  746  difference t (Tip k _) = delete k t 
745  747  difference t Nil = t 
746  748  
 749    /O(n+m)/. Difference between a map and a set of keys. 
 750   
 751   > differenceKeysSet a (keysSet b) == difference a b 
 752  
 753  differenceKeysSet :: IntMap a > IntSet.IntSet > IntMap a 
 754  differenceKeysSet t1@(Bin p1 m1 l1 r1) t2@(IntSet.Bin p2 m2 l2 r2) 
 755   shorter m1 m2 = difference1 
 756   shorter m2 m1 = difference2 
 757   p1 == p2 = bin p1 m1 (differenceKeysSet l1 l2) (differenceKeysSet r1 r2) 
 758   otherwise = t1 
 759  where 
 760  difference1  nomatch p2 p1 m1 = t1 
 761   zero p2 m1 = bin p1 m1 (differenceKeysSet l1 t2) r1 
 762   otherwise = bin p1 m1 l1 (differenceKeysSet r1 t2) 
 763  
 764  difference2  nomatch p1 p2 m2 = t1 
 765   zero p1 m2 = differenceKeysSet t1 l2 
 766   otherwise = differenceKeysSet t1 r2 
 767  
 768  differenceKeysSet t1@(Tip k _) t2 
 769   IntSet.member k t2 = Nil 
 770   otherwise = t1 
 771  
 772  differenceKeysSet Nil _ = Nil 
 773  differenceKeysSet t (IntSet.Tip k) = delete k t 
 774  differenceKeysSet t IntSet.Nil = t 
 775  
747  776    /O(n+m)/. Difference with a combining function. 
748  777   
749  778   > let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing 