collections

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 5 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorStopIteration = errors.New("stopped iteration")

Functions

func SliceContains

func SliceContains[T comparable](data []T, value T) bool

func SliceFindIndex added in v0.2.2

func SliceFindIndex[T any](data []T, cmp func(v T) bool) int

func SliceMap added in v0.2.2

func SliceMap[T any, U any](data []T, mapFn func(v T, i int) U) []U

func SliceReduce added in v0.2.2

func SliceReduce[T any, U any](data []T, reduceFn func(acc U, curr T, i int) U, initial U) U

Types

type ConcurrentMap added in v0.1.3

type ConcurrentMap[K comparable, T any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewConcurrentMap added in v0.1.3

func NewConcurrentMap[K comparable, T any]() *ConcurrentMap[K, T]

func NewConcurrentMapFrom added in v0.1.3

func NewConcurrentMapFrom[K comparable, T any](data map[K]T) *ConcurrentMap[K, T]

func NewConcurrentMapFromJSON added in v0.2.7

func NewConcurrentMapFromJSON[K comparable, T any](data []byte) (*ConcurrentMap[K, T], error)

func (*ConcurrentMap[K, T]) AsMap added in v0.1.6

func (cm *ConcurrentMap[K, T]) AsMap() map[K]T

AsMap creates a shallow copy of a map wrapped by this ConcurrentMap

func (*ConcurrentMap[K, T]) Delete added in v0.1.7

func (cm *ConcurrentMap[K, T]) Delete(k K)

func (*ConcurrentMap[K, T]) ForEach added in v0.1.3

func (cm *ConcurrentMap[K, T]) ForEach(fn func(k K, v T))

func (*ConcurrentMap[K, T]) Get added in v0.1.3

func (cm *ConcurrentMap[K, T]) Get(k K) T

func (*ConcurrentMap[K, T]) GetWithTest added in v0.1.3

func (cm *ConcurrentMap[K, T]) GetWithTest(k K) (T, bool)

func (*ConcurrentMap[K, T]) HasKey added in v0.1.3

func (cm *ConcurrentMap[K, T]) HasKey(k K) bool

func (*ConcurrentMap[K, T]) Keys added in v0.1.3

func (cm *ConcurrentMap[K, T]) Keys() []K

func (*ConcurrentMap[K, T]) Len added in v0.1.7

func (cm *ConcurrentMap[K, T]) Len() int

Len returns number of key-value pairs stored in the map

func (*ConcurrentMap[K, T]) MarshalJSON added in v0.2.7

func (cm *ConcurrentMap[K, T]) MarshalJSON() ([]byte, error)

func (*ConcurrentMap[K, T]) Set added in v0.1.3

func (cm *ConcurrentMap[K, T]) Set(k K, v T)

func (*ConcurrentMap[K, T]) Update added in v0.1.3

func (cm *ConcurrentMap[K, T]) Update(fn func(k K, v T) T)

func (*ConcurrentMap[K, T]) Values added in v0.1.3

func (cm *ConcurrentMap[K, T]) Values() []T

type Multidict

type Multidict[T any] struct {
	// contains filtered or unexported fields
}

func NewMultidict

func NewMultidict[T any]() *Multidict[T]

func (*Multidict[T]) Add

func (md *Multidict[T]) Add(k string, v T)

func (*Multidict[T]) ForEach

func (md *Multidict[T]) ForEach(applyFn func(k string, v []T) error) error

func (*Multidict[T]) Get

func (md *Multidict[T]) Get(k string) []T

type Set

type Set[T constraints.Ordered] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T constraints.Ordered](values ...T) *Set[T]

func (*Set[T]) Add

func (set *Set[T]) Add(value T)

func (*Set[T]) Contains

func (set *Set[T]) Contains(value T) bool

func (*Set[T]) ForEach

func (set *Set[T]) ForEach(fn func(item T))

func (*Set[T]) Remove

func (set *Set[T]) Remove(value T)

func (*Set[T]) ToOrderedSlice

func (set *Set[T]) ToOrderedSlice() []T

func (*Set[T]) ToSlice

func (set *Set[T]) ToSlice() []T

func (*Set[T]) Union

func (set *Set[T]) Union(other Set[T]) *Set[T]

Jump to

Keyboard shortcuts

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