generics

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SliceMap added in v0.0.11

func SliceMap[T any, U any](slice []T, fn func(T) U) []U

Types

type SafeMap

type SafeMap[K comparable, V comparable] struct {
	// contains filtered or unexported fields
}

SafeMap is a thread-safe map.

func NewSafeMap

func NewSafeMap[K comparable, V comparable](items ...Tuple[K, V]) *SafeMap[K, V]

NewSafeMap creates a new SafeMap.

func (*SafeMap[K, V]) Clear added in v0.0.15

func (m *SafeMap[K, V]) Clear()

Clear clears the map.

func (*SafeMap[K, V]) Delete

func (m *SafeMap[K, V]) Delete(key K)

Delete deletes a value from the map.

func (*SafeMap[K, V]) Get

func (m *SafeMap[K, V]) Get(key K) (V, bool)

Get gets a value from the map.

func (*SafeMap[K, V]) HasKey added in v0.0.15

func (m *SafeMap[K, V]) HasKey(key K) bool

HasKey checks if the map has the key.

func (*SafeMap[K, V]) HasValue added in v0.0.15

func (m *SafeMap[K, V]) HasValue(val V) bool

HasValue checks if the map has the value.

func (*SafeMap[K, V]) IsEmpty added in v0.0.15

func (m *SafeMap[K, V]) IsEmpty() bool

IsEmpty checks if the map is empty.

func (*SafeMap[K, V]) Iter

func (m *SafeMap[K, V]) Iter() <-chan Tuple[K, V]

Iter returns a channel that iterates over the map.

func (*SafeMap[K, V]) Keys added in v0.0.15

func (m *SafeMap[K, V]) Keys() []K

Keys returns all keys in the map.

func (*SafeMap[K, V]) Len

func (m *SafeMap[K, V]) Len() int

Len returns the length of the map.

func (*SafeMap[K, V]) MustGet added in v0.0.17

func (m *SafeMap[K, V]) MustGet(key K) V

MustGet gets a value from the map. Panics if the key does not exist.

func (*SafeMap[K, V]) Set

func (m *SafeMap[K, V]) Set(key K, val V)

Set sets a value in the map.

func (*SafeMap[K, V]) Values added in v0.0.15

func (m *SafeMap[K, V]) Values() []V

Values returns all values in the map.

type Tuple

type Tuple[T any, U any] struct {
	First  T
	Second U
}

func NewTuple

func NewTuple[T any, U any](first T, second U) Tuple[T, U]

NewTuple creates a new Tuple.

Jump to

Keyboard shortcuts

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