From 71d95c976f213e9d1eb8c1e0bfb6e8782499ecd2 Mon Sep 17 00:00:00 2001 From: Andrey Pechkurov Date: Sun, 25 Feb 2024 21:26:14 +0200 Subject: [PATCH] Improve NewMapPresized/NewMapOfPresized godoc --- map.go | 5 ++++- mapof.go | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/map.go b/map.go index c5cd5e2..e86b180 100644 --- a/map.go +++ b/map.go @@ -124,7 +124,10 @@ func NewMap() *Map { } // NewMapPresized creates a new Map instance with capacity enough to hold -// sizeHint entries. If sizeHint is zero or negative, the value is ignored. +// sizeHint entries. The capacity is treated as the minimal capacity +// meaning that the underlying hash table will never shrink to +// a smaller capacity. If sizeHint is zero or negative, the value +// is ignored. func NewMapPresized(sizeHint int) *Map { m := &Map{} m.resizeCond = *sync.NewCond(&m.resizeMu) diff --git a/mapof.go b/mapof.go index 4388662..ea767da 100644 --- a/mapof.go +++ b/mapof.go @@ -71,7 +71,9 @@ func NewMapOf[K comparable, V any]() *MapOf[K, V] { } // NewMapOfPresized creates a new MapOf instance with capacity enough -// to hold sizeHint entries. If sizeHint is zero or negative, the value +// to hold sizeHint entries. The capacity is treated as the minimal capacity +// meaning that the underlying hash table will never shrink to +// a smaller capacity. If sizeHint is zero or negative, the value // is ignored. func NewMapOfPresized[K comparable, V any](sizeHint int) *MapOf[K, V] { return newMapOfPresized[K, V](makeHasher[K](), sizeHint)