maps

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2022 License: Apache-2.0 Imports: 0 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL