File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,15 @@ module Data.HashSet
60
60
-- * Filter
61
61
, filter
62
62
63
+ -- * Conversions
64
+
63
65
-- ** Lists
64
66
, toList
65
67
, fromList
68
+
69
+ -- * HashMaps
70
+ , toMap
71
+ , fromMap
66
72
) where
67
73
68
74
import Control.DeepSeq (NFData (.. ))
@@ -148,6 +154,14 @@ singleton :: Hashable a => a -> HashSet a
148
154
singleton a = HashSet (H. singleton a () )
149
155
{-# INLINABLE singleton #-}
150
156
157
+ -- | /O(1)/ Convert to the equivalent 'HashMap'.
158
+ toMap :: HashSet a -> HashMap a ()
159
+ toMap = asMap
160
+
161
+ -- | /O(1)/ Convert from the equivalent 'HashMap'.
162
+ fromMap :: HashMap a () -> HashSet a
163
+ fromMap = HashSet
164
+
151
165
-- | /O(n+m)/ Construct a set containing all elements from both sets.
152
166
--
153
167
-- To obtain good performance, the smaller set must be presented as
You can’t perform that action at this time.
0 commit comments