maps

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 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]) 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.

Jump to

Keyboard shortcuts

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