Skip to content

Commit 67f7d11

Browse files
committed
Update time complexity of some HashSet functions
...for consistency with HashMap
1 parent 304dce1 commit 67f7d11

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Data/HashSet/Internal.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ delete :: Hashable a => a -> HashSet a -> HashSet a
377377
delete a = HashSet . H.delete a . asMap
378378
{-# INLINABLE delete #-}
379379

380-
-- | \(O(n)\) Transform this set by applying a function to every value.
380+
-- | \(O(n \log n)\) Transform this set by applying a function to every value.
381381
-- The resulting set may be smaller than the source.
382382
--
383383
-- >>> HashSet.map show (HashSet.fromList [1,2,3])
@@ -386,7 +386,7 @@ map :: Hashable b => (a -> b) -> HashSet a -> HashSet b
386386
map f = fromList . List.map f . toList
387387
{-# INLINE map #-}
388388

389-
-- | \(O(n)\) Difference of two sets. Return elements of the first set
389+
-- | \(O(n \log m)\) Difference of two sets. Return elements of the first set
390390
-- not existing in the second.
391391
--
392392
-- >>> HashSet.difference (HashSet.fromList [1,2,3]) (HashSet.fromList [2,3,4])
@@ -395,7 +395,7 @@ difference :: Eq a => HashSet a -> HashSet a -> HashSet a
395395
difference (HashSet a) (HashSet b) = HashSet (H.difference a b)
396396
{-# INLINABLE difference #-}
397397

398-
-- | \(O(n)\) Intersection of two sets. Return elements present in both
398+
-- | \(O(n \log m)\) Intersection of two sets. Return elements present in both
399399
-- the first set and the second.
400400
--
401401
-- >>> HashSet.intersection (HashSet.fromList [1,2,3]) (HashSet.fromList [2,3,4])
@@ -454,7 +454,7 @@ toList :: HashSet a -> [a]
454454
toList t = Exts.build (\ c z -> foldrWithKey (const . c) z (asMap t))
455455
{-# INLINE toList #-}
456456

457-
-- | \(O(n \min(W, n))\) Construct a set from a list of elements.
457+
-- | \(O(n \log n)\) Construct a set from a list of elements.
458458
fromList :: Hashable a => [a] -> HashSet a
459459
fromList = HashSet . List.foldl' (\ m k -> H.unsafeInsert k () m) H.empty
460460
{-# INLINE fromList #-}

0 commit comments

Comments
 (0)