structs

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func ArrToMap

func ArrToMap[K Hashable, T, U any](source []T, mapper func(T, int) (K, U)) map[K]U

func Concat

func Concat[T any](sources ...[]T) []T

func Contains

func Contains[T comparable](source []T, target T) bool

func Exist

func Exist[T any](source []T, mapper func(T) bool) bool

func ExistMap

func ExistMap[K Hashable, T any](source map[K]T, mapper func(K, T) bool) bool

func Filter

func Filter[T any](source []T, mapper func(T) bool) []T

func FilterMap

func FilterMap[K Hashable, T any](source map[K]T, mapper func(K, T) bool) map[K]T

func Index

func Index[T any](source []T, mapper func(T) bool) int

func Map

func Map[T, U any](source []T, mapper func(T) U) []U

func MapContains

func MapContains[T any, U comparable](source []T, mapper func(T) U, target U) bool

func MapToArr

func MapToArr[K Hashable, T any](source map[K]T) []T

func MapToArrMap

func MapToArrMap[K Hashable, T, U any](source map[K]T, mapper func(K, T) U) []U

func Max

func Max[T Integer](a ...T) T

func Min

func Min[T Integer](a ...T) T

func SafeIndex

func SafeIndex[T any](arr []*T, idx int) *T

func Uniq

func Uniq[T any, H Hashable](source []T, mapper func(T) H) []T

func WithIn

func WithIn[T Integer](t, a, b T) T

func WithInDefault

func WithInDefault[T Integer](t, a, b, defaultValue T) T

Types

type AsyncArr

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

func NewAsyncArr

func NewAsyncArr[T any]() *AsyncArr[T]

func (*AsyncArr[T]) Del

func (aa *AsyncArr[T]) Del(idx int) *T

func (*AsyncArr[T]) ForEach

func (aa *AsyncArr[T]) ForEach() []T

func (*AsyncArr[T]) Get

func (aa *AsyncArr[T]) Get(idx int) (*T, bool)

func (*AsyncArr[T]) Len added in v0.0.4

func (aa *AsyncArr[T]) Len() int

func (*AsyncArr[T]) MustGet

func (aa *AsyncArr[T]) MustGet(idx int) *T

func (*AsyncArr[T]) Push

func (aa *AsyncArr[T]) Push(val T)

func (*AsyncArr[T]) Set

func (aa *AsyncArr[T]) Set(idx int, val T) bool

func (*AsyncArr[T]) Take

func (aa *AsyncArr[T]) Take(idx int) *T

type AsyncMap

type AsyncMap[K Hashable, V any] struct {
	// contains filtered or unexported fields
}

func NewAsyncMap

func NewAsyncMap[K Hashable, T any]() *AsyncMap[K, T]

func (*AsyncMap[K, T]) Del

func (am *AsyncMap[K, T]) Del(key K)

func (*AsyncMap[K, T]) ForEach

func (am *AsyncMap[K, T]) ForEach() map[K]T

func (*AsyncMap[K, T]) Get

func (am *AsyncMap[K, T]) Get(key K) (T, bool)

func (*AsyncMap[K, T]) MustGet

func (am *AsyncMap[K, T]) MustGet(key K) T

func (*AsyncMap[K, T]) Set

func (am *AsyncMap[K, T]) Set(key K, val T)

func (*AsyncMap[K, T]) Take

func (am *AsyncMap[K, T]) Take(key K) (T, bool)

type Hashable

type Hashable interface {
	Ordered
}

type Integer

type Integer interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64
}

type Ordered

type Ordered interface {
	Integer | ~string
}

type Set

type Set[T Hashable] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T Hashable]() *Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(key T)

func (*Set[T]) Digest

func (s *Set[T]) Digest() []T

func (*Set[T]) Has

func (s *Set[T]) Has(key T) bool

func (*Set[T]) Remove

func (s *Set[T]) Remove(key T)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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