Documentation ¶
Index ¶
- type AccumFn
- type ErrHandler
- type GeneratorFn
- type Pipe
- func (p Pipe[T]) Any() *T
- func (p Pipe[T]) Count() int
- func (p Pipe[T]) Do() []T
- func (p Pipe[T]) Erase() Pipe[any]
- func (p Pipe[T]) Filter(fn func(*T) bool) Pipe[T]
- func (p Pipe[T]) First() *T
- func (p Pipe[T]) Gen(n int) Pipe[T]
- func (p Pipe[T]) Map(fn func(T) T) Pipe[T]
- func (p Pipe[T]) MapFilter(fn func(T) (T, bool)) Pipe[T]
- func (p Pipe[T]) Parallel(n uint16) Pipe[T]
- func (p Pipe[T]) Promices() []func() (T, bool)
- func (p Pipe[T]) Reduce(fn AccumFn[T]) *T
- func (p Pipe[T]) Snag(h ErrHandler) Pipe[T]
- func (p Pipe[T]) Sort(less func(*T, *T) bool) Pipe[T]
- func (p Pipe[T]) Sum(plus AccumFn[T]) T
- func (p Pipe[T]) Take(n int) Pipe[T]
- func (p Pipe[T]) Yeti(y YeetSnag) Pipe[T]
- type YeetSnag
- type Yeti
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrHandler ¶ added in v1.0.5
type ErrHandler func(error)
type GeneratorFn ¶
type Pipe ¶
type Pipe[T any] struct { Fn GeneratorFn[T] Len int ValLim int GoroutinesCnt int // contains filtered or unexported fields }
func Range ¶
func Range[T constraints.Integer | constraints.Float](start, finish, step T) Pipe[T]
func (Pipe[T]) Any ¶
func (p Pipe[T]) Any() *T
Any returns a pointer to a random element in the pipe or nil if none left.
func (Pipe[T]) Do ¶
func (p Pipe[T]) Do() []T
Do evaluates all the pipeline and returns the result slice.
func (Pipe[T]) Gen ¶
Gen set the amount of values to generate as initial array. It's applied only the first Gen() or Take() function in the pipe.
func (Pipe[T]) Map ¶
Map applies given function to each element of the underlying slice returns the slice where each element is n[i] = f(p[i]).
func (Pipe[T]) MapFilter ¶ added in v1.0.5
MapFilter applies given function to each element of the underlying slice, if the second returning value of fn is false, the element is skipped (may be useful for error handling). returns the slice where each element is n[i] = f(p[i]) if it is not skipped.
func (Pipe[T]) Parallel ¶
Parallel set n - the amount of goroutines to run on. Only the first Parallel() in a pipe chain is applied.
func (Pipe[T]) Reduce ¶
Reduce applies the result of a function to each element one-by-one: f(p[n], f(p[n-1], f(p[n-2, ...]))).
func (Pipe[T]) Snag ¶ added in v1.0.5
func (p Pipe[T]) Snag(h ErrHandler) Pipe[T]
Sang ads error handler to a current Pipe step.
func (Pipe[T]) Sum ¶
Sum returns the sum of all elements. It is similar to Reduce but is able to work in parallel.
type YeetSnag ¶ added in v1.0.5
type YeetSnag interface { // yeet an error Yeet(err error) // snag and handle the error Snag(ErrHandler) }