Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultHashMap ¶
type DefaultHashMap[K comparable, V any] struct { // contains filtered or unexported fields }
DefaultHashMap is a hash map that uses a factory to generate default value for missing keys. And it is not thread safe, for concurrent access use with a sync.Mutex.
func NewDefaultHashMap ¶
func NewDefaultHashMap[K comparable, V any](factory func(K) V) *DefaultHashMap[K, V]
NewDefaultHashMap returns a new DefaultHashMap.
func (*DefaultHashMap[K, V]) Del ¶
func (m *DefaultHashMap[K, V]) Del(key K)
Del deletes the value for the given key.
func (*DefaultHashMap[K, V]) Get ¶
func (m *DefaultHashMap[K, V]) Get(key K) V
Get returns the value for the given key.
func (*DefaultHashMap[K, V]) Has ¶
func (m *DefaultHashMap[K, V]) Has(key K) bool
Has returns true if the map contains the key.
func (*DefaultHashMap[K, V]) Range ¶
func (m *DefaultHashMap[K, V]) Range(f func(K, V))
Range calls the given function for each key-value pair in the map.
func (*DefaultHashMap[K, V]) Set ¶
func (m *DefaultHashMap[K, V]) Set(key K, val V)
Set sets the value for the given key.
Click to show internal directories.
Click to hide internal directories.