stl

package
v1.0.66 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NopLogger = zap.NewNop()
)

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 BatchAssertType added in v1.0.61

func BatchAssertType[Dst any, Source any, Sources ~[]Source](sources Sources) (result []Dst, allOk bool)

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 BatchProcessUntilFirstError added in v1.0.44

func BatchProcessUntilFirstError[Data any, Datas ~[]Data](datas Datas, f func(Data) error) error

func Bisect added in v1.0.63

func Bisect[Datas ~[]Data, Data any](datas Datas, tester func(Data) bool) (trues Datas, falses Datas)

func BisectByKeyAmbiguity added in v1.0.63

func BisectByKeyAmbiguity[Datas ~[]Data, Data any, Key comparable](datas Datas, key func(Data) Key) (unambiguous, ambiguous Datas)

func BuildMap added in v1.0.18

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

func BuildMapPro added in v1.0.18

func BuildMapPro[Map ~map[Key]Value, Datas ~[]Data, Key comparable, Value any, Data 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 ChainUnaryHandler added in v1.0.46

func ChainUnaryHandler[
	Data any,
	Arg any,
](handler func(*Data, Arg)) func(*Data, Arg) *Data

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](dst, src Map) Map

func ConcatMapInplace

func ConcatMapInplace[Map ~map[Key]Value, Key comparable, Value any](dst, src Map) Map

func ConcatMaps added in v1.0.40

func ConcatMaps[Map ~map[Key]Value, Key comparable, Value any](maps ...Map) Map

func ConcatMapsTo added in v1.0.40

func ConcatMapsTo[Map ~map[Key]Value, Key comparable, Value any](dst Map, maps ...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 Contain added in v1.0.47

func Contain[Datas ~[]Data, Data comparable](datas Datas, target Data) bool

func ContainAll added in v1.0.61

func ContainAll[Datas ~[]Data, Data comparable](datas Datas, targets ...Data) bool

func ContainAny added in v1.0.61

func ContainAny[Datas ~[]Data, Data comparable](datas Datas, targets ...Data) bool

func CountAndMap added in v1.0.44

func CountAndMap[
	Number interface {
		constraints.Integer | constraints.Float
	},
	Mapper func(Number) Data,
	Data any,
](start, end, step Number, mapper Mapper) []Data

func CountAndMapLite added in v1.0.44

func CountAndMapLite[
	Number interface {
		constraints.Integer | constraints.Float
	},
	Mapper func() Data,
	Data any,
](start, end, step Number, mapper Mapper) []Data

func CountAndMapPro added in v1.0.44

func CountAndMapPro[
	Number interface {
		constraints.Integer | constraints.Float
	},
	Mapper func(Number, []Data) Data,
	Data any,
](start, end, step Number, mapper Mapper) []Data

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 FilterMapByKey added in v1.0.61

func FilterMapByKey[Map ~map[Key]Value, Key comparable, Value any](m Map, f func(Key) bool) Map

func FilterMapByValue added in v1.0.61

func FilterMapByValue[Map ~map[Key]Value, Key comparable, Value any](m Map, f func(Value) 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 FilterZeroKey added in v1.0.63

func FilterZeroKey[Datas ~[]Data, Data any, Key comparable](datas Datas, key func(Data) Key) 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 ForEachByMapper added in v1.0.55

func ForEachByMapper[Data any, MappedData any](datas []Data, mapper func(data Data) MappedData)

func ForEachPro added in v1.0.3

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

func GetContextValue added in v1.0.56

func GetContextValue[Value any, Key any](ctx context.Context, key Key) (value Value)

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 LookupContextValue added in v1.0.56

func LookupContextValue[Value any, Key any](ctx context.Context, key Key) (value Value, ok bool)

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[DstMap ~map[DstKey]DstValue, DstKey comparable, DstValue any, SrcMap ~map[SrcKey]SrvValue, SrcKey comparable, SrvValue any](m SrcMap, mapper func(SrcKey, SrvValue, SrcMap) (DstKey, DstValue)) DstMap

func MapMapLite added in v1.0.44

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

func MapMapPro added in v1.0.53

func MapMapPro[DM ~map[DK]DV, SM ~map[SK]SV, SK comparable, SV any, DK comparable, DV any](sm SM, mapper func(sk SK, sv SV, sm SM, dm DM) (DK, DV, bool, error)) (DM, bool, error)

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 MapToAssertedType added in v1.0.61

func MapToAssertedType[Dst any, Source any, Sources ~[]Source](sources Sources) (result []Dst)

func MapUtilError added in v1.0.53

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

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 MultivalueMap added in v1.0.43

func MultivalueMap[Result ~map[Key]Values, Values ~[]Value, Map ~map[Key]Value, Key comparable, Value any](m Map) Result

func MustLookupContextValue added in v1.0.56

func MustLookupContextValue[Value any, Key any](ctx context.Context, key Key) (value Value)

func New added in v1.0.40

func New[Data any]() (data Data)

func NewPtr added in v1.0.40

func NewPtr[Ptr ~*Data, Data any]() Ptr

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 PurgeMapKeys added in v1.0.47

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

func PurgeMapZeroKey added in v1.0.47

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

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 PurgeZeroKey added in v1.0.58

func PurgeZeroKey[Datas ~[]Data, Data any, Key comparable](datas Datas, key func(Data) Key) 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 ReflectType added in v1.0.48

func ReflectType[T any]() reflect.Type

func Reverse added in v1.0.61

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

func SliceEmpty added in v1.0.55

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

func SliceEqual added in v1.0.11

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

func SliceLen added in v1.0.55

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

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 SliceNil added in v1.0.55

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

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 StableUniqueBySet added in v1.0.65

func StableUniqueBySet[Datas ~[]Data, Data comparable](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 TypeAsserter added in v1.0.61

func TypeAsserter[Dst any, Src any](src Src) (dst Dst, ok bool)

func UnchainUnaryHandler added in v1.0.46

func UnchainUnaryHandler[
	Data any,
	Arg any,
](handler func(Data, Arg) Data) func(Data, Arg)

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 {
	*zap.Logger
	// contains filtered or unexported fields
}

func NewCachedDataFetcher added in v1.0.29

func NewCachedDataFetcher[Data any](fetcher CachedDataFetcherFetchFunc[Data]) *CachedDataFetcher[Data]

func NewCachedDataFetcherLite added in v1.0.29

func NewCachedDataFetcherLite[Data any](fetcher CachedDataFetcherFetchFuncLite[Data]) *CachedDataFetcher[Data]

func (*CachedDataFetcher[Data]) BuildAccessor added in v1.0.64

func (fetcher *CachedDataFetcher[Data]) BuildAccessor() *CachedDataFetcherAccessor[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, time.Time, error)

func (*CachedDataFetcher[Data]) FetchLite added in v1.0.37

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

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

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

func (*CachedDataFetcher[Data]) FetchWithExpiresPro added in v1.0.64

func (fetcher *CachedDataFetcher[Data]) FetchWithExpiresPro(ctx context.Context, expiresDuration, fallbackDuration time.Duration, logger *zap.Logger) (data Data, ok bool)

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

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

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

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

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

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

func (*CachedDataFetcher[Data]) GetFetch added in v1.0.44

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

func (*CachedDataFetcher[Data]) GetFetchLite added in v1.0.44

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

func (*CachedDataFetcher[Data]) GetRefresh added in v1.0.44

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

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

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

func (*CachedDataFetcher[Data]) GetWithExpiresWarn added in v1.0.61

func (fetcher *CachedDataFetcher[Data]) GetWithExpiresWarn(expiresDuration time.Duration) (Data, bool)

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

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

func (*CachedDataFetcher[Data]) GetWithSinceWarn added in v1.0.61

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

func (*CachedDataFetcher[Data]) NewCallback added in v1.0.36

func (fetcher *CachedDataFetcher[Data]) NewCallback(callback CachedDataFetcherCallbackFunc[Data], timeout time.Duration) *CachedDataFetcherCallback[Data]

func (*CachedDataFetcher[Data]) NewCallbackLite added in v1.0.36

func (fetcher *CachedDataFetcher[Data]) NewCallbackLite(callback func(context.Context), timeout time.Duration) *CachedDataFetcherCallback[Data]

func (*CachedDataFetcher[Data]) PurgeCachedData added in v1.0.44

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

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

func (fetcher *CachedDataFetcher[Data]) Refresh(ctx context.Context) (data Data, t time.Time, err error)

func (*CachedDataFetcher[Data]) RegisterCallback added in v1.0.36

func (fetcher *CachedDataFetcher[Data]) RegisterCallback(callback *CachedDataFetcherCallback[Data]) *CachedDataFetcherCallback[Data]

func (*CachedDataFetcher[Data]) RegisterCallbackFuncLite added in v1.0.37

func (fetcher *CachedDataFetcher[Data]) RegisterCallbackFuncLite(callback func(context.Context), timeout time.Duration)

func (*CachedDataFetcher[Data]) SinceTimeFromExpiresDuration added in v1.0.39

func (fetcher *CachedDataFetcher[Data]) SinceTimeFromExpiresDuration(expiresDuration time.Duration) (since time.Time)

func (*CachedDataFetcher[Data]) TriggerRefresh added in v1.0.36

func (fetcher *CachedDataFetcher[Data]) TriggerRefresh(ctx context.Context)

func (*CachedDataFetcher[Data]) WithCachedDataPurged added in v1.0.44

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

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 CachedDataFetcherFetchFunc[Data]) *CachedDataFetcher[Data]

func (*CachedDataFetcher[Data]) WithLogger added in v1.0.57

func (fetcher *CachedDataFetcher[Data]) WithLogger(logger *zap.Logger) *CachedDataFetcher[Data]

func (*CachedDataFetcher[Data]) WithOthersSubscribed added in v1.0.38

func (fetcher *CachedDataFetcher[Data]) WithOthersSubscribed(timeout time.Duration, others ...interface {
	RegisterCallbackFuncLite(func(context.Context), time.Duration)
}) *CachedDataFetcher[Data]

type CachedDataFetcherAccessor added in v1.0.64

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

func (*CachedDataFetcherAccessor[Data]) Dup added in v1.0.64

func (getter *CachedDataFetcherAccessor[Data]) Dup() *CachedDataFetcherAccessor[Data]

func (*CachedDataFetcherAccessor[Data]) Get added in v1.0.64

func (getter *CachedDataFetcherAccessor[Data]) Get() (data Data, ok bool)

func (*CachedDataFetcherAccessor[Data]) GetLogger added in v1.0.64

func (getter *CachedDataFetcherAccessor[Data]) GetLogger() *zap.Logger

func (*CachedDataFetcherAccessor[Data]) WithExpiresDuration added in v1.0.64

func (getter *CachedDataFetcherAccessor[Data]) WithExpiresDuration(expiresDuration time.Duration) *CachedDataFetcherAccessor[Data]

func (*CachedDataFetcherAccessor[Data]) WithFallbackDuration added in v1.0.64

func (getter *CachedDataFetcherAccessor[Data]) WithFallbackDuration(fallbackDuration time.Duration) *CachedDataFetcherAccessor[Data]

func (*CachedDataFetcherAccessor[Data]) WithLogExpired added in v1.0.64

func (getter *CachedDataFetcherAccessor[Data]) WithLogExpired(logExpired bool) *CachedDataFetcherAccessor[Data]

func (*CachedDataFetcherAccessor[Data]) WithLogger added in v1.0.64

func (getter *CachedDataFetcherAccessor[Data]) WithLogger(logger *zap.Logger) *CachedDataFetcherAccessor[Data]

type CachedDataFetcherCallback added in v1.0.36

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

func NewCachedDataFetcherCallback added in v1.0.36

func NewCachedDataFetcherCallback[Data any](callback func(context.Context, Data, time.Time), timeout time.Duration) *CachedDataFetcherCallback[Data]

func (*CachedDataFetcherCallback[Data]) Call added in v1.0.36

func (callback *CachedDataFetcherCallback[Data]) Call(data Data, lastFetchTime time.Time)

type CachedDataFetcherCallbackFunc added in v1.0.36

type CachedDataFetcherCallbackFunc[Data any] func(context.Context, Data, time.Time)

type CachedDataFetcherCallbacks added in v1.0.36

type CachedDataFetcherCallbacks[Data any] []*CachedDataFetcherCallback[Data]

func (CachedDataFetcherCallbacks[Data]) Append added in v1.0.36

func (callbacks CachedDataFetcherCallbacks[Data]) Append(others ...*CachedDataFetcherCallback[Data]) CachedDataFetcherCallbacks[Data]

func (CachedDataFetcherCallbacks[Data]) Call added in v1.0.36

func (callbacks CachedDataFetcherCallbacks[Data]) Call(data Data, lastFetchTime time.Time)

type CachedDataFetcherFetchFunc added in v1.0.38

type CachedDataFetcherFetchFunc[Data any] func(ctx context.Context, expires time.Duration) (Data, time.Time, error)

type CachedDataFetcherFetchFuncLite added in v1.0.38

type CachedDataFetcherFetchFuncLite[Data any] func(ctx context.Context) (Data, error)

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 ContextValues added in v1.0.56

type ContextValues[Key comparable, Value any] map[Key]Value

func NewContextValues added in v1.0.56

func NewContextValues[Key comparable, Value any]() ContextValues[Key, Value]

func (ContextValues[Key, Value]) ApplyTo added in v1.0.56

func (values ContextValues[Key, Value]) ApplyTo(ctx context.Context) context.Context

func (ContextValues[Key, Value]) Empty added in v1.0.56

func (values ContextValues[Key, Value]) Empty() bool

func (ContextValues[Key, Value]) Len added in v1.0.56

func (values ContextValues[Key, Value]) Len() int

func (ContextValues[Key, Value]) With added in v1.0.56

func (values ContextValues[Key, Value]) With(key Key, value Value) ContextValues[Key, Value]

type Counter added in v1.0.60

type Counter[Key comparable] map[Key]int

func Count added in v1.0.60

func Count[Datas ~[]Data, Data comparable](datas Datas) Counter[Data]

func CountByKey added in v1.0.53

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

func NewCounter added in v1.0.60

func NewCounter[Key comparable]() Counter[Key]

func (Counter[Key]) Decrease added in v1.0.60

func (counter Counter[Key]) Decrease(key Key) Counter[Key]

func (Counter[Key]) Increase added in v1.0.60

func (counter Counter[Key]) Increase(key Key) Counter[Key]

func (Counter[Key]) IncreaseValue added in v1.0.60

func (counter Counter[Key]) IncreaseValue(key Key, value int) Counter[Key]

func (Counter[Key]) NativeMap added in v1.0.60

func (counter Counter[Key]) NativeMap() map[Key]int

func (Counter[Key]) SumKeys added in v1.0.60

func (counter Counter[Key]) SumKeys(keys ...Key) (total int)

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 NewErrors added in v1.0.54

func NewErrors(errs ...error) Errors

func (Errors) Append added in v1.0.54

func (errors Errors) Append(more ...error) Errors

func (Errors) Concat added in v1.0.54

func (errors Errors) Concat(mores ...Errors) 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

func (Errors) Simplify added in v1.0.46

func (errors Errors) Simplify() error

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
}

func (*KeyValuePair[Key, Value]) GetKey added in v1.0.56

func (pair *KeyValuePair[Key, Value]) GetKey() (key Key)

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 ZipToPairs added in v1.0.53

func ZipToPairs[Key any, Value any](keys []Key, values []Value) KeyValuePairs[Key, Value]

func (KeyValuePairs[Key, Value]) Append added in v1.0.56

func (pairs KeyValuePairs[Key, Value]) Append(others ...KeyValuePair[Key, Value]) KeyValuePairs[Key, Value]

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

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

type Mapping added in v1.0.56

type Mapping[Key comparable, Value any] map[Key]Value

func NewMapping added in v1.0.56

func NewMapping[Key comparable, Value any]() Mapping[Key, Value]

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]) ContainAll added in v1.0.49

func (set Set[Data]) ContainAll(datas ...Data) bool

func (Set[Data]) ContainAny added in v1.0.49

func (set Set[Data]) ContainAny(datas ...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]) Append added in v1.0.57

func (slice Slice[Data]) Append(datas ...Data) Slice[Data]

func (Slice[Data]) Concat added in v1.0.57

func (slice Slice[Data]) Concat(others ...Slice[Data]) Slice[Data]

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]

type TimedValue added in v1.0.37

type TimedValue[Value any] struct {
	// contains filtered or unexported fields
}

func NewTimedValue added in v1.0.37

func NewTimedValue[Value any](value Value, t time.Time) *TimedValue[Value]

func (*TimedValue[Value]) Time added in v1.0.37

func (timed *TimedValue[Value]) Time() (t time.Time)

func (*TimedValue[Value]) Value added in v1.0.37

func (timed *TimedValue[Value]) Value() (value Value)

func (*TimedValue[Value]) ValueAndTime added in v1.0.37

func (timed *TimedValue[Value]) ValueAndTime() (value Value, t time.Time)

Jump to

Keyboard shortcuts

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