[add IdMap, use new SetLike setup
John Meacham <john@repetae.net>**20060409053253] hunk ./Name/Id.hs 7
-    IdSet()
+    IdSet(),
+    IdMap(),
+    idSetToIdMap,
+    idMapToIdSet
hunk ./Name/Id.hs 16
+import qualified Data.IntMap  as IM
hunk ./Name/Id.hs 27
+
+-- IdSet
+
+
hunk ./Name/Id.hs 32
-    deriving(Typeable,Monoid,HasSize,SetLike)
+    deriving(Typeable,Monoid,HasSize,SetLike,BuildSet Id,ModifySet Id)
hunk ./Name/Id.hs 34
-instance BuildSet IdSet Id where
-    fromList xs = IdSet $ IS.fromList (map idToInt xs)
-    fromDistinctAscList xs = IdSet $ IS.fromDistinctAscList (map idToInt xs)
-    member x (IdSet s) = IS.member (idToInt x) s
-    insert x (IdSet s) = IdSet $ IS.insert (idToInt x) s
-    delete x (IdSet s) = IdSet $ IS.delete (idToInt x) s
-    singleton x = IdSet $ IS.singleton (idToInt x)
hunk ./Name/Id.hs 41
+
+-- IdMap
+
+newtype IdMap a = IdMap (IM.IntMap a)
+    deriving(Typeable,Monoid,HasSize,SetLike,BuildSet (Id,a),MapLike Id a)
+
+
+idSetToIdMap :: (Id -> a) -> IdSet -> IdMap a
+idSetToIdMap f (IdSet is) = IdMap $ IM.fromDistinctAscList [ (x,f x) |  x <- IS.toAscList is]
+
+idMapToIdSet :: IdMap a -> IdSet
+idMapToIdSet (IdMap im) = IdSet $ IS.fromDistinctAscList (IM.keys im)
+
+