Documentation
¶
Index ¶
- type DefaultHashMap
- func (m DefaultHashMap[K, V]) Clone() DefaultHashMap[K, V]
- func (m DefaultHashMap[K, V]) Contains(key K) bool
- func (m DefaultHashMap[K, V]) ContainsAll(keys []K) bool
- func (m DefaultHashMap[K, V]) Del(key K)
- func (m DefaultHashMap[K, V]) Get(key K) V
- func (m DefaultHashMap[K, V]) Range(f func(K, V))
- func (m DefaultHashMap[K, V]) Set(key K, val V)
- func (m DefaultHashMap[K, V]) Size() int
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]) Clone ¶ added in v0.2.1
func (m DefaultHashMap[K, V]) Clone() DefaultHashMap[K, V]
Clone returns a copy of the map.
func (DefaultHashMap[K, V]) Contains ¶ added in v0.2.1
func (m DefaultHashMap[K, V]) Contains(key K) bool
Contains returns true if the map contains the key.
func (DefaultHashMap[K, V]) ContainsAll ¶ added in v0.2.1
func (m DefaultHashMap[K, V]) ContainsAll(keys []K) bool
ContainsAll returns true if the map contains all the given keys.
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]) 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.
func (DefaultHashMap[K, V]) Size ¶ added in v0.2.1
func (m DefaultHashMap[K, V]) Size() int
Size returns the number of key-value pairs in the map.
Click to show internal directories.
Click to hide internal directories.