Skip to content

Commit 7c66911

Browse files
authored
Fixes docs of Data.HashMap.Lazy.fromList: it takes O(n * log(n)) (#498)
Fixes the incorrect documentation in Data.HashMap.Lazy.fromList / Data.HashMap.Internal.fromList: This takes linearithmic time rather than linear time, since we do n insertions, each of which takes (assuming no collisions!) log32(n) steps as per the documentation of insert. Fixes #309
1 parent 333ccb3 commit 7c66911

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Data/HashMap/Internal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2233,7 +2233,7 @@ toList :: HashMap k v -> [(k, v)]
22332233
toList t = Exts.build (\ c z -> foldrWithKey (curry c) z t)
22342234
{-# INLINE toList #-}
22352235

2236-
-- | \(O(n)\) Construct a map with the supplied mappings. If the list
2236+
-- | \(O(n \log n)\) Construct a map with the supplied mappings. If the list
22372237
-- contains duplicate mappings, the later mappings take precedence.
22382238
fromList :: (Eq k, Hashable k) => [(k, v)] -> HashMap k v
22392239
fromList = List.foldl' (\ m (k, v) -> unsafeInsert k v m) empty

0 commit comments

Comments
 (0)