Documentation ¶
Index ¶
- func FirstVal[T any](v ...*T) *T
- func Generator[T any](ctx context.Context, size int, ...) <-chan T
- func GeneratorSimple[T any](size int, genFn func(prev T) (T, bool)) <-chan T
- func MapEqual[T ~map[K]V, K comparable, V comparable](mp, otherMap T) bool
- func MapReduce[K comparable, V any, R any](mp map[K]V, reduce func(key K, val V, ret *R)) R
- func Max[T constraints.Ordered](x, y T) T
- func Min[T constraints.Ordered](x, y T) T
- func SliceReduce[T any, R any](sl []T, reduce func(val T, ret *R)) R
- func SliceUnique[T comparable](sl []T) []T
- type LazySlice
- type Map
- func (mp Map[K, V]) Apply(apply func(key K, val V) (K, V)) Map[K, V]
- func (mp Map[K, V]) Copy() Map[K, V]
- func (mp Map[K, V]) Each(iter func(key K, val V)) Map[K, V]
- func (mp Map[K, V]) Filter(filter func(key K, val V) bool) Map[K, V]
- func (mp Map[K, V]) Keys() Slice[K]
- func (mp Map[K, V]) Merge(maps ...Map[K, V]) Map[K, V]
- func (mp Map[K, V]) MergeConflict(conflictFunc func(V, V) V, maps ...Map[K, V]) Map[K, V]
- func (mp Map[K, V]) ReduceIntoOne(reduce func(key K, val V, ret *V)) V
- func (mp Map[K, V]) Set(key K, val V) Map[K, V]
- func (mp Map[K, V]) Values() Slice[V]
- type Slice
- func (sl Slice[T]) Append(val T) Slice[T]
- func (sl Slice[T]) Apply(apply func(val T) T) Slice[T]
- func (sl Slice[T]) BinarySearch(fn func(val T) bool) int
- func (sl Slice[T]) Copy() Slice[T]
- func (sl Slice[T]) Each(iter func(val T)) Slice[T]
- func (sl Slice[T]) Filter(filter func(val T) bool) Slice[T]
- func (sl Slice[T]) First() *T
- func (sl Slice[T]) FirstOr(def T) T
- func (sl Slice[T]) Has(fn func(val T) bool) bool
- func (sl Slice[T]) IndexOf(fn func(val T) bool) int
- func (sl Slice[T]) Last() *T
- func (sl Slice[T]) LastOr(def T) T
- func (sl Slice[T]) Len() int
- func (sl Slice[T]) Prepend(val T) Slice[T]
- func (sl Slice[T]) ReduceIntoOne(apply func(val T, ret *T)) T
- func (sl Slice[T]) RemoveAt(i int) Slice[T]
- func (sl Slice[T]) RemoveRange(i, j int) Slice[T]
- func (sl Slice[T]) Sort(cmp func(a, b T) bool) Slice[T]
- func (sl Slice[T]) ValueOr(i int, def T) T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generator ¶
func Generator[T any](ctx context.Context, size int, genFn func(ctx context.Context, prev T) (T, bool)) <-chan T
Generator returns generator with context Done support
func GeneratorSimple ¶
GeneratorSimple returns generator which is not controlled from external
func MapEqual ¶
func MapEqual[T ~map[K]V, K comparable, V comparable](mp, otherMap T) bool
MapEqual comparing two maps of the same type
func MapReduce ¶
func MapReduce[K comparable, V any, R any](mp map[K]V, reduce func(key K, val V, ret *R)) R
MapReduce map and return new value
func Max ¶
func Max[T constraints.Ordered](x, y T) T
Max value Deprecated: use `max` in go1.21+ instead.
func Min ¶
func Min[T constraints.Ordered](x, y T) T
Min value Deprecated: use `min` in go1.21+ instead.
func SliceReduce ¶
SliceReduce slice and return new value
func SliceUnique ¶
func SliceUnique[T comparable](sl []T) []T
SliceUnique return new slice without duplicated values
Types ¶
type LazySlice ¶
type LazySlice[T any] struct { // contains filtered or unexported fields }
LazySlice type extended with banch of processing methods
func NewLazySlice ¶
NewLazySlice creates new lazy slice
type Map ¶
type Map[K comparable, V any] map[K]V
Map type extended with banch of processing methods
func MapApply ¶
func MapApply[K comparable, V any, NK comparable, NV any](mp map[K]V, apply func(key K, val V) (NK, NV)) Map[NK, NV]
AmpApply the function to each element of the map
func (Map[K, V]) MergeConflict ¶ added in v0.2.0
MergeConflict maps into one with conflict function resolver
func (Map[K, V]) ReduceIntoOne ¶
func (mp Map[K, V]) ReduceIntoOne(reduce func(key K, val V, ret *V)) V
ReduceIntoOne map and return single value
type Slice ¶
type Slice[T any] []T
Slice type extended with banch of processing methods
func SliceApply ¶
SliceApply the function to each element of the slice
func (Slice[T]) BinarySearch ¶
BinarySearch slice values
func (Slice[T]) FirstOr ¶
func (sl Slice[T]) FirstOr(def T) T
FirstOr value from slice or default value
func (Slice[T]) LastOr ¶
func (sl Slice[T]) LastOr(def T) T
LastOr value from slice or default value
func (Slice[T]) ReduceIntoOne ¶
func (sl Slice[T]) ReduceIntoOne(apply func(val T, ret *T)) T
ReduceIntoOne slice and return new single value
func (Slice[T]) RemoveRange ¶
RemoveRange values from slice