Documentation
¶
Overview ¶
Package weakmap implements weak map, a map which references its values without preventing reclamation of memory used by them.
Index ¶
Constants ¶
View Source
const DefaultN = 5
DefaultN is overhead goal parameter, which corresponds to 25% inactive elements overhead.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map implements weak map. It is safe for concurrent use by multiple goroutines.
func Make ¶
func Make[K comparable, V any]() *Map[K, V]
Make creates new weak map with default overhead goal.
func Make1 ¶
func Make1[K comparable, V any](n int) *Map[K, V]
Make1 creates new weak map with specified overhead goal parameter.
func (*Map[K, V]) Get ¶
func (m *Map[K, V]) Get(key K) *V
Get lookups key in weak map. It returns nil pointer if key doesn't exist in map or its value was already reclaimed.
Click to show internal directories.
Click to hide internal directories.