\begin{code}
module UniqSet (
+ -- * Unique set type
UniqSet, -- abstract type: NOT
+ -- ** Manipulating these sets
mkUniqSet, uniqSetToList, emptyUniqSet, unitUniqSet,
- addOneToUniqSet, addListToUniqSet,
- delOneFromUniqSet, delListFromUniqSet,
+ addOneToUniqSet, addListToUniqSet, addOneToUniqSet_C,
+ delOneFromUniqSet, delListFromUniqSet, delOneFromUniqSet_Directly,
unionUniqSets, unionManyUniqSets, minusUniqSet,
elementOfUniqSet, mapUniqSet, intersectUniqSets,
isEmptyUniqSet, filterUniqSet, sizeUniqSet, foldUniqSet,
) where
import Maybes
-import LazyUniqFM
+import UniqFM
import Unique
#if ! OMIT_NATIVE_CODEGEN
addOneToUniqSet :: Uniquable a => UniqSet a -> a -> UniqSet a
addOneToUniqSet (MkUniqSet set) x = MkUniqSet (addToUFM set x x)
+addOneToUniqSet_C :: Uniquable a
+ => (a -> a -> a) -> UniqSet a -> a -> UniqSet a
+addOneToUniqSet_C f (MkUniqSet set) x = MkUniqSet (addToUFM_C f set x x)
+
delOneFromUniqSet :: Uniquable a => UniqSet a -> a -> UniqSet a
delOneFromUniqSet (MkUniqSet set) x = MkUniqSet (delFromUFM set x)
+delOneFromUniqSet_Directly :: Uniquable a => UniqSet a -> Unique -> UniqSet a
+delOneFromUniqSet_Directly (MkUniqSet set) u
+ = MkUniqSet (delFromUFM_Directly set u)
+
delListFromUniqSet :: Uniquable a => UniqSet a -> [a] -> UniqSet a
delListFromUniqSet (MkUniqSet set) xs = MkUniqSet (delListFromUFM set xs)
isEmptyUniqSet :: UniqSet a -> Bool
isEmptyUniqSet (MkUniqSet set) = isNullUFM set {-SLOW: sizeUFM set == 0-}
-mapUniqSet :: (a -> a) -> UniqSet a -> UniqSet a
- -- VERY IMPORTANT: *assumes* that the function doesn't change the unique
+-- | Invariant: the mapping function doesn't change the unique
+mapUniqSet :: (a -> b) -> UniqSet a -> UniqSet b
mapUniqSet f (MkUniqSet set) = MkUniqSet (mapUFM f set)
\end{code}