Skip to content

Commit c83961f

Browse files
authored
Call out that Int{Set,Map}.size is not O(1) (#1138)
1 parent 51ef2cf commit c83961f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

containers/src/Data/IntMap/Internal.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,9 @@ null Nil = True
575575
null _ = False
576576
{-# INLINE null #-}
577577

578-
-- | \(O(n)\). Number of elements in the map.
578+
-- | \(O(n)\). Number of entries in the map.
579+
--
580+
-- __Note__: Unlike @Data.Map.'Data.Map.Lazy.size'@, this is /not/ \(O(1)\).
579581
--
580582
-- > size empty == 0
581583
-- > size (singleton 1 'a') == 1

containers/src/Data/IntSet/Internal.hs

+2
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ null _ = False
360360

361361
-- | \(O(n)\). Cardinality of the set.
362362
--
363+
-- __Note__: Unlike @Data.Set.'Data.Set.size'@, this is /not/ \(O(1)\).
364+
--
363365
-- See also: 'compareSize'
364366
size :: IntSet -> Int
365367
size = go 0

0 commit comments

Comments
 (0)