stl

package
v1.0.35 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllMatch

func AllMatch[Data any](datas []Data, test func(Data) bool) bool

func AllMatchPro added in v1.0.3

func AllMatchPro[Data any, Datas ~[]Data](datas Datas, test func(int, Data, Datas) bool) bool

func AnyMatch

func AnyMatch[Data any](datas []Data, test func(Data) bool) bool

func AnyMatchPro added in v1.0.3

func AnyMatchPro[Data any, Datas ~[]Data](datas Datas, test func(int, Data, Datas) bool) bool

func Backmost added in v1.0.32

func Backmost[Datas ~[]Data, Data any](datas Datas, before func(a, b Data) bool) (result Data, index int)

func BackmostPro added in v1.0.32

func BackmostPro[Datas ~[]Data, Data any](datas Datas, before func(a, b Data) bool) (result Data, index int)

func BatchDeleteMap

func BatchDeleteMap[Key comparable, Keys ~[]Key, Value any, Map ~map[Key]Value](m Map, keys Keys) Map

func BatchDeleteMapFromAnother

func BatchDeleteMapFromAnother[Key comparable, Value any, Map ~map[Key]Value](m Map, keys Map) Map

func BuildMap added in v1.0.18

func BuildMap[Datas ~[]Data, Map ~map[Key]Value, Data any, Key comparable, Value any](datas Datas, kv func(data Data) (Key, Value)) Map

func BuildMapPro added in v1.0.18

func BuildMapPro[Datas ~[]Data, Map ~map[Key]Value, Data any, Key comparable, Value any](datas Datas, kv func(data Data) (Key, Value, bool, error)) (Map, error)

func CacheMapValue added in v1.0.8

func CacheMapValue[Key comparable, Value any, Map ~map[Key]Value](m Map, key Key, value Value) Value

func CacheMapValueWithInitializer added in v1.0.8

func CacheMapValueWithInitializer[Key comparable, Value any, Map ~map[Key]Value](m Map, key Key, initializer func() Value) Value

func Compare added in v1.0.8

func Compare[Data constraints.Ordered](as []Data, bs []Data) int

func ConcatMap

func ConcatMap[Key comparable, Value any, Map ~map[Key]Value](m1, m2 Map) Map

func ConcatMapInplace

func ConcatMapInplace[Key comparable, Value any, Map ~map[Key]Value](m1, m2 Map) Map

func ConcatSlices

func ConcatSlices[Data any, Slice ~[]Data](slices ...Slice) Slice

func ConcatSlicesTo

func ConcatSlicesTo[Data any, Slice ~[]Data](slice Slice, slices ...Slice) Slice

func Dereference added in v1.0.35

func Dereference[Ptr ~*Data, Data any](ptr Ptr) Data

func Divide added in v1.0.33

func Divide[Datas ~[]Data, Data any](datas Datas, size int, dup bool) (subs []Datas)

func Dup added in v1.0.7

func Dup[Data any, Ptr ~*Data](ptr Ptr) Ptr

func DupMap

func DupMap[Key comparable, Value any, Map ~map[Key]Value](m Map) Map

func DupSlice

func DupSlice[Data any, Slice ~[]Data](slice Slice) Slice

func Echo added in v1.0.35

func Echo[Data any](data Data) Data

func EqualBySet added in v1.0.8

func EqualBySet[Data comparable](as []Data, bs []Data) bool

func EqualBySort added in v1.0.8

func EqualBySort[Data constraints.Ordered](as []Data, bs []Data) bool

func FillSliceToCap added in v1.0.8

func FillSliceToCap[Data any, Datas ~[]Data](datas Datas, g func(int) Data) Datas

func Filter

func Filter[Data any, Datas ~[]Data](datas Datas, filter func(Data) bool) Datas

func FilterMap added in v1.0.28

func FilterMap[Map ~map[Key]Value, Key comparable, Value any](m Map, tester func(Key, Value, Map) bool) Map

func FilterPro added in v1.0.3

func FilterPro[Data any, Datas ~[]Data](datas Datas, filter func(int, Data, Datas) bool) Datas

func FindFirst added in v1.0.23

func FindFirst[Datas ~[]Data, Data any](datas Datas, test func(Data) bool) (Data, bool)

func FindFirstNotZero added in v1.0.26

func FindFirstNotZero[Data comparable](datas []Data) Data

func FindFirstOrDefault added in v1.0.23

func FindFirstOrDefault[Data any](datas []Data, test func(Data) bool, defaultData Data) Data

func FindFirstOrZero added in v1.0.23

func FindFirstOrZero[Data any](datas []Data, test func(Data) bool) Data

func FindLast added in v1.0.22

func FindLast[Data any](datas []Data, test func(Data) bool) (Data, bool)

func FindLastOrDefault added in v1.0.22

func FindLastOrDefault[Data any](datas []Data, test func(Data) bool, defaultData Data) Data

func FindLastOrZero added in v1.0.22

func FindLastOrZero[Data any](datas []Data, test func(Data) bool) Data

func FirstOneOrZero added in v1.0.26

func FirstOneOrZero[Datas ~[]Data, Data any](datas Datas) (data Data)

func ForEach

func ForEach[Data any](datas []Data, handler func(data Data))

func ForEachPro added in v1.0.3

func ForEachPro[Data any, Datas ~[]Data](datas Datas, handler func(i int, data Data, datas Datas))

func GetSliceElemPointers

func GetSliceElemPointers[Data any, Datas ~[]Data](datas Datas) []*Data

func Headmost added in v1.0.32

func Headmost[Datas ~[]Data, Data any](datas Datas, before func(a, b Data) bool) (result Data)

func HeadmostPro added in v1.0.32

func HeadmostPro[Datas ~[]Data, Data any](datas Datas, before func(a, b Data) bool) (result Data, index int)

func Index added in v1.0.17

func Index[Data any](datas []Data, i int) (data Data, ok bool)

func IndexOf

func IndexOf[Data comparable](datas []Data, target Data) int

func InstancesToPointers

func InstancesToPointers[Data any, Instances ~[]Data](instances Instances) []*Data

func JoinSlices added in v1.0.26

func JoinSlices[Slice ~[]Data, Data any](sep Slice, slices ...Slice) Slice

func JoinSlicesTo added in v1.0.26

func JoinSlicesTo[Slice ~[]Data, Data any](slice Slice, sep Slice, keepFirstSep bool, slices ...Slice) Slice

func LastOneOrZero added in v1.0.31

func LastOneOrZero[Datas ~[]Data, Data any](datas Datas) (data Data)

func Map

func Map[Data any, Datas ~[]Data, Result any](datas Datas, mapper func(Data) Result) []Result

func MapAndConcat

func MapAndConcat[Data any, Datas ~[]Data, Result any, Results ~[]Result](datas Datas, mapper func(Data) Results) Results

func MapAndConcatWithError added in v1.0.26

func MapAndConcatWithError[Datas ~[]Data, Results ~[]Result, Data any, Result any](datas Datas, stopWhenError bool, mapper func(Data) (Results, error)) (Results, error)

func MapAndJoinWithError added in v1.0.26

func MapAndJoinWithError[Datas ~[]Data, Results ~[]Result, Data any, Result any](datas Datas, sep Results, stopWhenError bool, mapper func(Data) (Results, error)) (Results, error)

func MapArgs

func MapArgs[Data any, Result any](mapper func(Data) Result, args ...Data) []Result

func MapIterator added in v1.0.35

func MapIterator[Data any, Result any](it Iterator[Data], mapper func(Data) Result) []Result

func MapKeys

func MapKeys[Map ~map[Key]Value, Key comparable, Value any](m Map) []Key

func MapMap added in v1.0.27

func MapMap[Map ~map[Key]Value, Key comparable, Value any](m Map, mapper func(Key, Value, Map) (Key, Value)) Map

func MapMapToSlice added in v1.0.27

func MapMapToSlice[Slice ~[]SliceItem, Map ~map[Key]Value, SliceItem any, Key comparable, Value any](m Map, convert func(Key, Value, Map) SliceItem) Slice

func MapMapToSlicePro added in v1.0.27

func MapMapToSlicePro[Slice ~[]SliceItem, Map ~map[Key]Value, SliceItem any, Key comparable, Value any](m Map, convert func(Key, Value, Map) (SliceItem, bool, error)) (Slice, error)

func MapPro added in v1.0.3

func MapPro[Data any, Datas ~[]Data, Result any](datas Datas, mapper func(int, Data, Datas) Result) []Result

func MapProArgs added in v1.0.3

func MapProArgs[Data any, Datas ~[]Data, Result any](mapper func(int, Data, Datas) Result, datas ...Data) []Result

func MapValueGetter added in v1.0.17

func MapValueGetter[Key comparable, Value any, Map ~map[Key]Value](m Map) func(Key) Value

func MapValueGetterPro added in v1.0.17

func MapValueGetterPro[Key comparable, Value any, Map ~map[Key]Value](m Map, keys ...Key) func(Key) (Value, bool)

func MapValues added in v1.0.6

func MapValues[Key comparable, Value any, Map ~map[Key]Value](m Map) []Value

func MapValuesByKeys added in v1.0.6

func MapValuesByKeys[Key comparable, Value any, Map ~map[Key]Value](m Map, keys ...Key) []Value

func MappingByKey

func MappingByKey[Data any, Datas ~[]Data, Key comparable](datas Datas, key func(Data) Key) map[Key]Data

func MappingByKeyPro added in v1.0.3

func MappingByKeyPro[Data any, Datas ~[]Data, Key comparable](datas Datas, key func(int, Data, Datas) Key) map[Key]Data

func MappingByKeys

func MappingByKeys[Data any, Datas ~[]Data, Key comparable, Keys ~[]Key](datas Datas, keys func(Data) Keys) map[Key]Data

func Max added in v1.0.19

func Max[Datas ~[]Data, Data constraints.Ordered](datas Datas, _default Data) (result Data)

func Min added in v1.0.19

func Min[Datas ~[]Data, Data constraints.Ordered](datas Datas, _default Data) (result Data)

func PopMap

func PopMap[Key comparable, Value any, Map ~map[Key]Value](m Map, key Key) (value Value, ok bool)

func Purge

func Purge[Data any, Datas ~[]Data](datas Datas, filter func(Data) bool) Datas

func PurgeValue

func PurgeValue[Data comparable, Datas ~[]Data](datas Datas, value Data) Datas

func PurgeZero

func PurgeZero[Data comparable, Datas ~[]Data](datas Datas) Datas

func ReadChan added in v1.0.8

func ReadChan[Data any](c chan Data, n int) []Data

func ReadChanAll added in v1.0.8

func ReadChanAll[Data any, Datas ~[]Data](c chan Data) (datas Datas)

func Reduce

func Reduce[Data any, Datas ~[]Data, Result any](datas Datas, reducer func(Result, Data) Result, initial Result) (result Result)

func ReducePro added in v1.0.3

func ReducePro[Data any, Datas ~[]Data, Result any](datas Datas, reducer func(Result, Data, int, Datas) Result, initial Result) (result Result)

func Reference added in v1.0.35

func Reference[Data any](data Data) *Data

func SliceEqual added in v1.0.11

func SliceEqual[Datas ~[]Data, Data comparable](as Datas, bs Datas) bool

func SliceMappingByKey

func SliceMappingByKey[Data any, Datas ~[]Data, Key comparable](datas Datas, key func(Data) Key) map[Key]Datas

func SliceMappingByKeys

func SliceMappingByKeys[Data any, Datas ~[]Data, Key comparable, Keys ~[]Key](datas Datas, keys func(Data) Keys) map[Key]Datas

func Sort

func Sort[Data any, Datas ~[]Data](datas Datas, less func(a, b Data) bool) Datas

func SortFast

func SortFast[Data constraints.Ordered, Datas ~[]Data](datas Datas) Datas

func SortUniqueFast

func SortUniqueFast[Data constraints.Ordered, Datas ~[]Data](datas Datas) Datas

func SubMapByKeys added in v1.0.17

func SubMapByKeys[Key comparable, Value any, Map ~map[Key]Value](m Map, keys ...Key) Map

func Sum added in v1.0.19

func Sum[Datas ~[]Data, Data Addend](datas Datas, start Data) Data

func ToTypeless added in v1.0.35

func ToTypeless[Data any](data Data) any

func ToTypelessSlice added in v1.0.35

func ToTypelessSlice[Datas ~[]Data, Data any](datas Datas) []any

func Unique

func Unique[Data comparable, Datas ~[]Data](datas Datas, equal func(Data, Data) bool) Datas

func UniqueByKeySet added in v1.0.11

func UniqueByKeySet[Datas ~[]Data, Data any, Key comparable](datas Datas, key func(Data) Key) Datas

func UniqueBySet

func UniqueBySet[Data comparable, Datas ~[]Data](datas Datas) Datas

func UniqueSorteds added in v1.0.11

func UniqueSorteds[Data comparable, Datas ~[]Data](datas Datas) Datas

Types

type Addend added in v1.0.19

type Addend interface {
	constraints.Integer | constraints.Float
}

type CachedDataFetcher added in v1.0.29

type CachedDataFetcher[Data any] struct {
	// contains filtered or unexported fields
}

func NewCachedDataFetcher added in v1.0.29

func NewCachedDataFetcher[Data any](fetcher func(context.Context) (Data, time.Time, error)) *CachedDataFetcher[Data]

func NewCachedDataFetcherLite added in v1.0.29

func NewCachedDataFetcherLite[Data any](fetcher func(context.Context) (Data, error)) *CachedDataFetcher[Data]

func (*CachedDataFetcher[Data]) Dup added in v1.0.31

func (fetcher *CachedDataFetcher[Data]) Dup() *CachedDataFetcher[Data]

func (*CachedDataFetcher[Data]) EnsureExpiresDuration added in v1.0.34

func (fetcher *CachedDataFetcher[Data]) EnsureExpiresDuration(expiresDuration time.Duration) *CachedDataFetcher[Data]

func (*CachedDataFetcher[Data]) Fetch added in v1.0.29

func (fetcher *CachedDataFetcher[Data]) Fetch(ctx context.Context) (Data, bool, error)

func (*CachedDataFetcher[Data]) FetchWithExpires added in v1.0.34

func (fetcher *CachedDataFetcher[Data]) FetchWithExpires(ctx context.Context, expiresDuration time.Duration) (data Data, ok bool, err error)

func (*CachedDataFetcher[Data]) FetchWithSince added in v1.0.34

func (fetcher *CachedDataFetcher[Data]) FetchWithSince(ctx context.Context, since time.Time) (data Data, ok bool, err error)

func (*CachedDataFetcher[Data]) Get added in v1.0.29

func (fetcher *CachedDataFetcher[Data]) Get() (Data, bool)

func (*CachedDataFetcher[Data]) GetCached added in v1.0.34

func (fetcher *CachedDataFetcher[Data]) GetCached() (Data, time.Time)

func (*CachedDataFetcher[Data]) GetWithExpires added in v1.0.34

func (fetcher *CachedDataFetcher[Data]) GetWithExpires(expiresDuration time.Duration) (data Data, ok bool)

func (*CachedDataFetcher[Data]) GetWithSince added in v1.0.34

func (fetcher *CachedDataFetcher[Data]) GetWithSince(since time.Time) (data Data, ok bool)

func (*CachedDataFetcher[Data]) Refresh added in v1.0.29

func (fetcher *CachedDataFetcher[Data]) Refresh(ctx context.Context) (data Data, ok bool, err error)

func (*CachedDataFetcher[Data]) WithExpiresDuration added in v1.0.30

func (fetcher *CachedDataFetcher[Data]) WithExpiresDuration(duration time.Duration) *CachedDataFetcher[Data]

func (*CachedDataFetcher[Data]) WithFetcher added in v1.0.30

func (fetcher *CachedDataFetcher[Data]) WithFetcher(fetcherFunc func(context.Context) (Data, time.Time, error)) *CachedDataFetcher[Data]

type ComparableSlice added in v1.0.8

type ComparableSlice[Data comparable] []Data

func NewComparableSlice added in v1.0.8

func NewComparableSlice[Data comparable](datas ...Data) ComparableSlice[Data]

func (ComparableSlice[Data]) AllMatch added in v1.0.8

func (slice ComparableSlice[Data]) AllMatch(f func(Data) bool) bool

func (ComparableSlice[Data]) AnyMatch added in v1.0.8

func (slice ComparableSlice[Data]) AnyMatch(f func(Data) bool) bool

func (ComparableSlice[Data]) Contain added in v1.0.11

func (slice ComparableSlice[Data]) Contain(data Data) bool

func (ComparableSlice[Data]) ContainAll added in v1.0.11

func (slice ComparableSlice[Data]) ContainAll(datas ...Data) bool

func (ComparableSlice[Data]) ContainAny added in v1.0.11

func (slice ComparableSlice[Data]) ContainAny(datas ...Data) bool

func (ComparableSlice[Data]) Dup added in v1.0.8

func (slice ComparableSlice[Data]) Dup() ComparableSlice[Data]

func (ComparableSlice[Data]) Filter added in v1.0.8

func (slice ComparableSlice[Data]) Filter(f func(Data) bool) ComparableSlice[Data]

func (ComparableSlice[Data]) ForEachPro added in v1.0.8

func (slice ComparableSlice[Data]) ForEachPro(f func(int, Data, ComparableSlice[Data]))

func (ComparableSlice[Data]) Map added in v1.0.8

func (slice ComparableSlice[Data]) Map(f func(Data) Data) Slice[Data]

func (ComparableSlice[Data]) Native added in v1.0.8

func (slice ComparableSlice[Data]) Native() []Data

func (ComparableSlice[Data]) NotNilSlice added in v1.0.8

func (slice ComparableSlice[Data]) NotNilSlice() ComparableSlice[Data]

type Errors added in v1.0.26

type Errors []error

func MapWithError added in v1.0.26

func MapWithError[Datas ~[]Data, Result any, Data any](datas Datas, stopWhenError bool, mapper func(Data) (Result, error)) (results []Result, errs Errors)

func MapWithErrorPro added in v1.0.34

func MapWithErrorPro[Datas ~[]Data, Result any, Data any](datas Datas, stopWhenError bool, mapper func(int, Data, Datas) (Result, error)) (results []Result, errs Errors)

func (Errors) Empty added in v1.0.26

func (errors Errors) Empty() bool

func (Errors) Error added in v1.0.26

func (errors Errors) Error() string

func (Errors) FirstError added in v1.0.26

func (errors Errors) FirstError() error

func (Errors) FirstOneOrZero added in v1.0.26

func (errors Errors) FirstOneOrZero() error

func (Errors) Len added in v1.0.26

func (errors Errors) Len() int

func (Errors) PurgeZero added in v1.0.26

func (errors Errors) PurgeZero() Errors

type Iterator added in v1.0.35

type Iterator[Data any] interface {
	Len() int
	Data() Data
	Next() bool
}

type KeyValuePair added in v1.0.27

type KeyValuePair[Key any, Value any] struct {
	Key   Key
	Value Value
}

type KeyValuePairPtrs added in v1.0.27

type KeyValuePairPtrs[Key any, Value any] []*KeyValuePair[Key, Value]

func MapKeyValuePairPtrs added in v1.0.27

func MapKeyValuePairPtrs[Map ~map[Key]Value, Key comparable, Value any](m Map) KeyValuePairPtrs[Key, Value]

func (KeyValuePairPtrs[Key, Value]) ToTypelessSlice added in v1.0.35

func (pairs KeyValuePairPtrs[Key, Value]) ToTypelessSlice() []any

type KeyValuePairs added in v1.0.27

type KeyValuePairs[Key any, Value any] []KeyValuePair[Key, Value]

func MapKeyValuePairs added in v1.0.27

func MapKeyValuePairs[Map ~map[Key]Value, Key comparable, Value any](m Map) KeyValuePairs[Key, Value]

func (KeyValuePairs[Key, Value]) ToTypelessSlice added in v1.0.35

func (pairs KeyValuePairs[Key, Value]) ToTypelessSlice() []any

type Set

type Set[Data comparable] map[Data]struct{}

func NewEmptySet

func NewEmptySet[Data comparable]() Set[Data]

func NewSet

func NewSet[Data comparable](datas ...Data) Set[Data]

func (Set[Data]) Add

func (set Set[Data]) Add(data Data) Set[Data]

func (Set[Data]) AddX added in v1.0.11

func (set Set[Data]) AddX(datas ...Data) Set[Data]

func (Set[Data]) Contain

func (set Set[Data]) Contain(data Data) bool

func (Set[Data]) Difference

func (set Set[Data]) Difference(other Set[Data]) Set[Data]

func (Set[Data]) Dup

func (set Set[Data]) Dup() Set[Data]

func (Set[Data]) Empty

func (set Set[Data]) Empty() bool

func (Set[Data]) Equal

func (set Set[Data]) Equal(other Set[Data]) bool

func (Set[Data]) FirstAppear added in v1.0.8

func (set Set[Data]) FirstAppear(datas ...Data) (result Data)

func (Set[Data]) Intersection

func (set Set[Data]) Intersection(other Set[Data]) Set[Data]

func (Set[Data]) Len

func (set Set[Data]) Len() int

func (Set[Data]) Merge added in v1.0.11

func (set Set[Data]) Merge(other Set[Data]) Set[Data]

func (Set[Data]) Pop

func (set Set[Data]) Pop(data Data) Set[Data]

func (Set[Data]) Purge added in v1.0.11

func (set Set[Data]) Purge(other Set[Data]) Set[Data]

func (Set[Data]) Push

func (set Set[Data]) Push(data Data) Set[Data]

func (Set[Data]) PushX

func (set Set[Data]) PushX(datas ...Data) Set[Data]

func (Set[Data]) Slice

func (set Set[Data]) Slice() Slice[Data]

func (Set[Data]) SymmetricDifference

func (set Set[Data]) SymmetricDifference(other Set[Data]) Set[Data]

func (Set[Data]) Union

func (set Set[Data]) Union(other Set[Data]) Set[Data]

type Slice added in v1.0.8

type Slice[Data any] []Data

func NewSlice added in v1.0.6

func NewSlice[Data any](datas ...Data) Slice[Data]

func (Slice[Data]) AllMatch added in v1.0.8

func (slice Slice[Data]) AllMatch(f func(Data) bool) bool

func (Slice[Data]) AnyMatch added in v1.0.8

func (slice Slice[Data]) AnyMatch(f func(Data) bool) bool

func (Slice[Data]) Dup added in v1.0.8

func (slice Slice[Data]) Dup() Slice[Data]

func (Slice[Data]) Filter added in v1.0.8

func (slice Slice[Data]) Filter(f func(Data) bool) Slice[Data]

func (Slice[Data]) FilterPro added in v1.0.14

func (slice Slice[Data]) FilterPro(f func(int, Data, Slice[Data]) bool) Slice[Data]

func (Slice[Data]) ForEach added in v1.0.14

func (slice Slice[Data]) ForEach(f func(Data))

func (Slice[Data]) ForEachPro added in v1.0.8

func (slice Slice[Data]) ForEachPro(f func(int, Data, Slice[Data]))

func (Slice[Data]) Map added in v1.0.8

func (slice Slice[Data]) Map(f func(Data) Data) Slice[Data]

func (Slice[Data]) MapPro added in v1.0.14

func (slice Slice[Data]) MapPro(f func(int, Data, Slice[Data]) Data) Slice[Data]

func (Slice[Data]) Native added in v1.0.8

func (slice Slice[Data]) Native() []Data

func (Slice[Data]) NotNilSlice added in v1.0.8

func (slice Slice[Data]) NotNilSlice() Slice[Data]

Jump to

Keyboard shortcuts

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