Skip to content

Commit 68cb389

Browse files
committed
Remove bold from some "Complexity" clauses for comparison.
1 parent 96d480c commit 68cb389

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Data/HashSet/Base.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ singleton a = HashSet (H.singleton a ())
283283
-- >>> HashSet.toMap (HashSet.singleton 1)
284284
-- fromList [(1,())]
285285
--
286-
-- __Complexity:__ /O(1)/
286+
-- /Complexity:/ /O(1)/
287287
toMap :: HashSet a -> HashMap a ()
288288
toMap = asMap
289289

@@ -292,7 +292,7 @@ toMap = asMap
292292
-- >>> HashSet.fromMap (HashMap.singleton 1 ())
293293
-- fromList [1]
294294
--
295-
-- __Complexity:__ /O(1)/
295+
-- /Complexity:/ /O(1)/
296296
fromMap :: HashMap a () -> HashSet a
297297
fromMap = HashSet
298298

@@ -301,7 +301,7 @@ fromMap = HashSet
301301
-- >>> HashSet.keysSet (HashMap.fromList [(1, "a"), (2, "b")]
302302
-- fromList [1,2]
303303
--
304-
-- __Complexity:__ /O(n)/
304+
-- /Complexity:/ /O(n)/
305305
--
306306
-- @since 0.2.10.0
307307
keysSet :: HashMap k a -> HashSet k
@@ -346,7 +346,8 @@ null = H.null . asMap
346346
-- >>> HashSet.size (HashSet.fromList [1,2,3])
347347
-- 3
348348
--
349-
-- __Complexity:__ /O(n)/
349+
-- __Complexity:__ /O(n)/ - The implementation of @HashSet@ does not save the
350+
-- size in a field so must traverse the entire data structure on each call.
350351
size :: HashSet a -> Int
351352
size = H.size . asMap
352353
{-# INLINE size #-}
@@ -468,7 +469,7 @@ foldl f z0 = foldlWithKey g z0 . asMap
468469
-- | Filter this set by retaining only elements satisfying a
469470
-- predicate.
470471
--
471-
-- __Complexity:__ /O(n)/
472+
-- /Complexity:/ /O(n)/
472473
filter :: (a -> Bool) -> HashSet a -> HashSet a
473474
filter p = HashSet . H.filterWithKey q . asMap
474475
where q k _ = p k
@@ -477,14 +478,14 @@ filter p = HashSet . H.filterWithKey q . asMap
477478
-- | Return a list of this set's elements. The list is
478479
-- produced lazily.
479480
--
480-
-- __Complexity:__ /O(n)/
481+
-- /Complexity:/ /O(n)/
481482
toList :: HashSet a -> [a]
482483
toList t = build (\ c z -> foldrWithKey ((const .) c) z (asMap t))
483484
{-# INLINE toList #-}
484485

485486
-- | Construct a set from a list of elements.
486487
--
487-
-- __Complexity:__ /O(n*min(W, n))/
488+
-- /Complexity:/ /O(n*min(W, n))/
488489
fromList :: (Eq a, Hashable a) => [a] -> HashSet a
489490
fromList = HashSet . List.foldl' (\ m k -> H.insert k () m) H.empty
490491
{-# INLINE fromList #-}

0 commit comments

Comments
 (0)