generics

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 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 any] struct {
	// contains filtered or unexported fields
}

SafeMap is a thread-safe map.

func NewSafeMap

func NewSafeMap[K comparable, V any]() *SafeMap[K, V]

NewSafeMap creates a new SafeMap.

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]) Iter

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

Iter returns a channel that iterates over 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]) Set

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

Set sets a value 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