Documentation ¶
Overview ¶
Package loop provides helpers for loop operation and iterator implementations
Index ¶
- Variables
- func Accum[T any](first T, next func() (T, bool, error), merge func(T, T) T) (accumulator T, err error)
- func Accumm[T any](first T, next func() (T, bool, error), merge func(T, T) (T, error)) (accumulator T, err error)
- func All[T any](next func() (T, bool, error), consumer func(T, error) bool)
- func Append[T any, TS ~[]T](next func() (T, bool, error), out TS) (TS, error)
- func Contains[T comparable](next func() (T, bool, error), example T) (bool, error)
- func ConvAndReduce[From, To any](next func() (From, bool, error), converter func(From) (To, error), ...) (out To, err error)
- func ConvertAndReduce[From, To any](next func() (From, bool, error), converter func(From) To, ...) (out To, err error)
- func ExtraKey[T, K any](next func() (T, bool, error), keysExtractor func(T) K) breakkvloop.Loop[K, T]
- func ExtraKeys[T, K any](next func() (T, bool, error), keysExtractor func(T) []K) breakkvloop.Loop[K, T]
- func ExtraKeyss[T, K any](next func() (T, bool, error), keyExtractor func(T) (K, error)) breakkvloop.Loop[K, T]
- func ExtraKeyy[T, K any](next func() (T, bool, error), keyExtractor func(T) (K, error)) breakkvloop.Loop[K, T]
- func ExtraVals[T, V any](next func() (T, bool, error), valsExtractor func(T) []V) breakkvloop.Loop[T, V]
- func ExtraValss[T, V any](next func() (T, bool, error), valsExtractor func(T) ([]V, error)) breakkvloop.Loop[T, V]
- func ExtraValue[T, V any](next func() (T, bool, error), valueExtractor func(T) V) breakkvloop.Loop[T, V]
- func ExtraValuee[T, V any](next func() (T, bool, error), valExtractor func(T) (V, error)) breakkvloop.Loop[T, V]
- func First[T any](next func() (T, bool, error), predicate func(T) bool) (out T, ok bool, err error)
- func Firstt[T any](next func() (T, bool, error), predicate func(T) (bool, error)) (out T, ok bool, err error)
- func For[T any](next func() (T, bool, error), consumer func(T) error) error
- func ForFiltered[T any](next func() (T, bool, error), consumer func(T) error, predicate func(T) bool) error
- func Group[T any, K comparable, V any](next func() (T, bool, error), keyExtractor func(T) K, valExtractor func(T) V) (map[K][]V, error)
- func GroupByMultiple[T any, K comparable, V any](next func() (T, bool, error), keysExtractor func(T) []K, ...) (map[K][]V, error)
- func GroupByMultipleKeys[T any, K comparable, V any](next func() (T, bool, error), keysExtractor func(T) []K, ...) (map[K][]V, error)
- func GroupByMultipleValues[T any, K comparable, V any](next func() (T, bool, error), keyExtractor func(T) K, ...) (map[K][]V, error)
- func Groupp[T any, K comparable, V any](next func() (T, bool, error), keyExtractor func(T) (K, error), ...) (map[K][]V, error)
- func HasAny[T any](next func() (T, bool, error), predicate func(T) bool) (bool, error)
- func HasAnyy[T any](next func() (T, bool, error), predicate func(T) (bool, error)) (bool, error)
- func KeyValue[T any, K, V any](next func() (T, bool, error), keyExtractor func(T) K, valExtractor func(T) V) breakkvloop.Loop[K, V]
- func KeyValuee[T any, K, V any](next func() (T, bool, error), keyExtractor func(T) (K, error), ...) breakkvloop.Loop[K, V]
- func KeyValues[T, K, V any](next func() (T, bool, error), keyExtractor func(T) K, ...) breakkvloop.Loop[K, V]
- func KeyValuess[T, K, V any](next func() (T, bool, error), keyExtractor func(T) (K, error), ...) breakkvloop.Loop[K, V]
- func KeysValue[T, K, V any](next func() (T, bool, error), keysExtractor func(T) []K, ...) breakkvloop.Loop[K, V]
- func KeysValuee[T, K, V any](next func() (T, bool, error), keysExtractor func(T) ([]K, error), ...) breakkvloop.Loop[K, V]
- func KeysValues[T, K, V any](next func() (T, bool, error), keysExtractor func(T) ([]K, error), ...) breakkvloop.Loop[K, V]
- func Map[T any, K comparable, V any](next func() (T, bool), keyExtractor func(T) K, valExtractor func(T) V) (map[K]V, error)
- func MapResolvv[T any, K comparable, V, VR any](next func() (T, bool, error), keyExtractor func(T) (K, error), ...) (m map[K]VR, err error)
- func Mapp[T any, K comparable, V any](next func() (T, bool, error), keyExtractor func(T) (K, error), ...) (map[K]V, error)
- func Of[T any](elements ...T) func() (e T, ok bool, err error)
- func Reduce[T any](next func() (T, bool, error), merge func(T, T) T) (T, error)
- func ReduceOK[T any](next func() (T, bool, error), merge func(T, T) T) (result T, ok bool, err error)
- func Reducee[T any](next func() (T, bool, error), merge func(T, T) (T, error)) (T, error)
- func ReduceeOK[T any](next func() (T, bool, error), merge func(T, T) (T, error)) (result T, ok bool, err error)
- func Slice[T any](next func() (T, bool, error)) (out []T, err error)
- func SliceCap[T any](next func() (T, bool, error), cap int) (out []T, err error)
- func Sum[T c.Summable](next func() (T, bool, error)) (T, error)
- func To[T any](next func() (T, bool, error), errConsumer func(error)) func() (T, bool)
- func Track[I, T any](next func() (I, T, bool, error), consumer func(I, T) error) error
- type Loop
- func Conv[From, To any](next func() (From, bool, error), converter func(From) (To, error)) Loop[To]
- func ConvOK[From, To any](next func() (From, bool, error), ...) Loop[To]
- func Convert[From, To any](next func() (From, bool, error), converter func(From) To) Loop[To]
- func ConvertAndFilter[From, To any](next func() (From, bool, error), converter func(From) (To, error), ...) Loop[To]
- func ConvertOK[From, To any](next func() (From, bool, error), converter func(from From) (To, bool)) Loop[To]
- func Crank[T any](next func() (T, bool, error)) (n Loop[T], t T, ok bool, err error)
- func Filt[T any](next func() (T, bool, error), filter func(T) (bool, error)) Loop[T]
- func FiltAndConv[From, To any](next func() (From, bool, error), filter func(From) (bool, error), ...) Loop[To]
- func FiltAndFlat[From, To any](next func() (From, bool, error), filter func(From) (bool, error), ...) Loop[To]
- func FiltFlattFilt[From, To any](next func() (From, bool, error), filterFrom func(From) (bool, error), ...) Loop[To]
- func Filter[T any](next func() (T, bool, error), filter func(T) bool) Loop[T]
- func FilterAndConvert[From, To any](next func() (From, bool, error), filter func(From) bool, ...) Loop[To]
- func FilterAndFlat[From, To any](next func() (From, bool, error), filter func(From) bool, ...) Loop[To]
- func FilterConvertFilter[From, To any](next func() (From, bool, error), filter func(From) (bool, error), ...) Loop[To]
- func FilterFlatFilter[From, To any](next func() (From, bool, error), filterFrom func(From) bool, ...) Loop[To]
- func Flat[From, To any](next func() (From, bool, error), flattener func(From) []To) Loop[To]
- func FlatAndFilt[From, To any](next func() (From, bool, error), flattener func(From) ([]To, error), ...) Loop[To]
- func Flatt[From, To any](next func() (From, bool, error), flattener func(From) ([]To, error)) Loop[To]
- func FlattAndFilter[From, To any](next func() (From, bool, error), flattener func(From) []To, ...) Loop[To]
- func From[T any](next func() (T, bool)) Loop[T]
- func New[S, T any](source S, hasNext func(S) bool, getNext func(S) (T, error)) Loop[T]
- func NoNilPtrVal[T any](next func() (*T, bool, error)) Loop[T]
- func NotNil[T any](next func() (*T, bool, error)) Loop[*T]
- func PtrVal[T any](next func() (*T, bool, error)) Loop[T]
- func S[TS ~[]T, T any](elements TS) Loop[T]
- func (next Loop[T]) Accum(first T, merge func(T, T) T) (T, error)
- func (next Loop[T]) Accumm(first T, merge func(T, T) (T, error)) (T, error)
- func (next Loop[T]) All(consumer func(T, error) bool)
- func (next Loop[T]) Append(out []T) ([]T, error)
- func (next Loop[T]) Crank() (Loop[T], T, bool, error)
- func (next Loop[T]) Filter(filter func(T) bool) Loop[T]
- func (next Loop[T]) First(predicate func(T) bool) (T, bool, error)
- func (next Loop[T]) For(consumer func(T) error) error
- func (next Loop[T]) HasAny(predicate func(T) bool) (bool, error)
- func (next Loop[T]) Reduce(merge func(T, T) T) (T, error)
- func (next Loop[T]) ReduceOK(merge func(T, T) T) (result T, ok bool, err error)
- func (next Loop[T]) Reducee(merge func(T, T) (T, error)) (T, error)
- func (next Loop[T]) ReduceeOK(merge func(T, T) (T, error)) (result T, ok bool, err error)
- func (next Loop[T]) Slice() ([]T, error)
- func (next Loop[T]) SliceCap(cap int) ([]T, error)
Constants ¶
This section is empty.
Variables ¶
var Break = c.Break
Break is the 'break' statement of the For, Track methods.
Functions ¶
func Accum ¶ added in v0.0.13
func Accum[T any](first T, next func() (T, bool, error), merge func(T, T) T) (accumulator T, err error)
Accum accumulates a value by using the 'first' argument to initialize the accumulator and sequentially applying the 'merge' functon to the accumulator and each element retrieved by the 'next' function.
func Accumm ¶ added in v0.0.13
func Accumm[T any](first T, next func() (T, bool, error), merge func(T, T) (T, error)) (accumulator T, err error)
Accumm accumulates a value by using the 'first' argument to initialize the accumulator and sequentially applying the 'merge' functon to the accumulator and each element retrieved by the 'next' function.
func All ¶ added in v0.0.13
All is an adapter for the next function for iterating by `for ... range`. Supported since go 1.22 with GOEXPERIMENT=rangefunc enabled.
func Append ¶ added in v0.0.8
Append collects the elements retrieved by the 'next' function into the specified 'out' slice
func Contains ¶
func Contains[T comparable](next func() (T, bool, error), example T) (bool, error)
Contains finds the first element that equal to the example and returns true
func ConvAndReduce ¶ added in v0.0.8
func ConvAndReduce[From, To any](next func() (From, bool, error), converter func(From) (To, error), merge func(To, To) To) (out To, err error)
ConvAndReduce converts each elements and merges them into one
func ConvertAndReduce ¶ added in v0.0.8
func ConvertAndReduce[From, To any](next func() (From, bool, error), converter func(From) To, merge func(To, To) To) (out To, err error)
ConvertAndReduce converts each elements and merges them into one
func ExtraKey ¶ added in v0.0.10
func ExtraKey[T, K any](next func() (T, bool, error), keysExtractor func(T) K) breakkvloop.Loop[K, T]
ExtraKey transforms a loop to the key/value loop based on applying key extractor to the elements
func ExtraKeys ¶ added in v0.0.10
func ExtraKeys[T, K any](next func() (T, bool, error), keysExtractor func(T) []K) breakkvloop.Loop[K, T]
ExtraKeys transforms a loop to the key/value loop based on applying key extractor to the elements
func ExtraKeyss ¶ added in v0.0.10
func ExtraKeyss[T, K any](next func() (T, bool, error), keyExtractor func(T) (K, error)) breakkvloop.Loop[K, T]
ExtraKeyss transforms a loop to the key/value loop based on applying key extractor to the elements
func ExtraKeyy ¶ added in v0.0.10
func ExtraKeyy[T, K any](next func() (T, bool, error), keyExtractor func(T) (K, error)) breakkvloop.Loop[K, T]
ExtraKeyy transforms a loop to the key/value loop based on applying key extractor to the elements
func ExtraVals ¶ added in v0.0.10
func ExtraVals[T, V any](next func() (T, bool, error), valsExtractor func(T) []V) breakkvloop.Loop[T, V]
ExtraVals transforms a loop to the key/value loop based on applying value extractor to the elements
func ExtraValss ¶ added in v0.0.10
func ExtraValss[T, V any](next func() (T, bool, error), valsExtractor func(T) ([]V, error)) breakkvloop.Loop[T, V]
ExtraValss transforms a loop to the key/value loop based on applying values extractor to the elements
func ExtraValue ¶ added in v0.0.10
func ExtraValue[T, V any](next func() (T, bool, error), valueExtractor func(T) V) breakkvloop.Loop[T, V]
ExtraValue transforms a loop to the key/value loop based on applying value extractor to the elements
func ExtraValuee ¶ added in v0.0.10
func ExtraValuee[T, V any](next func() (T, bool, error), valExtractor func(T) (V, error)) breakkvloop.Loop[T, V]
ExtraValuee transforms a loop to the key/value loop based on applying value extractor to the elements
func First ¶
First returns the first element that satisfies the condition of the 'predicate' function
func Firstt ¶ added in v0.0.8
func Firstt[T any](next func() (T, bool, error), predicate func(T) (bool, error)) (out T, ok bool, err error)
Firstt returns the first element that satisfies the condition of the 'predicate' function
func For ¶
For applies the 'consumer' function for the elements retrieved by the 'next' function until the consumer returns the c.Break to stop.
func ForFiltered ¶
func ForFiltered[T any](next func() (T, bool, error), consumer func(T) error, predicate func(T) bool) error
ForFiltered applies the 'consumer' function to the elements retrieved by the 'next' function that satisfy the 'predicate' function condition
func Group ¶
func Group[T any, K comparable, V any](next func() (T, bool, error), keyExtractor func(T) K, valExtractor func(T) V) (map[K][]V, error)
Group converts elements retrieved by the 'next' function into a new map, extracting a key for each element applying the converter 'keyExtractor'. The keyExtractor converts an element to a key. The valExtractor converts an element to a value.
func GroupByMultiple ¶
func GroupByMultiple[T any, K comparable, V any](next func() (T, bool, error), keysExtractor func(T) []K, valsExtractor func(T) []V) (map[K][]V, error)
GroupByMultiple converts elements retrieved by the 'next' function into a new map, extracting multiple keys, values per each element applying the 'keysExtractor' and 'valsExtractor' functions. The keysExtractor retrieves one or more keys per element. The valsExtractor retrieves one or more values per element.
func GroupByMultipleKeys ¶
func GroupByMultipleKeys[T any, K comparable, V any](next func() (T, bool, error), keysExtractor func(T) []K, valExtractor func(T) V) (map[K][]V, error)
GroupByMultipleKeys converts elements retrieved by the 'next' function into a new map, extracting multiple keys, one value per each element applying the 'keysExtractor' and 'valExtractor' functions. The keysExtractor retrieves one or more keys per element. The valExtractor converts an element to a value.
func GroupByMultipleValues ¶
func GroupByMultipleValues[T any, K comparable, V any](next func() (T, bool, error), keyExtractor func(T) K, valsExtractor func(T) []V) (map[K][]V, error)
GroupByMultipleValues converts elements retrieved by the 'next' function into a new map, extracting one key, multiple values per each element applying the 'keyExtractor' and 'valsExtractor' functions. The keyExtractor converts an element to a key. The valsExtractor retrieves one or more values per element.
func Groupp ¶ added in v0.0.10
func Groupp[T any, K comparable, V any](next func() (T, bool, error), keyExtractor func(T) (K, error), valExtractor func(T) (V, error)) (map[K][]V, error)
Groupp converts elements retrieved by the 'next' function into a new map, extracting a key for each element applying the converter 'keyExtractor'. The keyExtractor converts an element to a key. The valExtractor converts an element to a value.
func HasAny ¶
HasAny finds the first element that satisfies the 'predicate' function condition and returns true if successful
func HasAnyy ¶ added in v0.0.8
HasAnyy finds the first element that satisfies the 'predicate' function condition and returns true if successful
func KeyValue ¶ added in v0.0.10
func KeyValue[T any, K, V any](next func() (T, bool, error), keyExtractor func(T) K, valExtractor func(T) V) breakkvloop.Loop[K, V]
KeyValue transforms a loop to the key/value loop based on applying key, value extractors to the elements
func KeyValuee ¶ added in v0.0.10
func KeyValuee[T any, K, V any](next func() (T, bool, error), keyExtractor func(T) (K, error), valExtractor func(T) (V, error)) breakkvloop.Loop[K, V]
KeyValuee transforms a loop to the key/value loop based on applying key, value extractors to the elements
func KeyValues ¶ added in v0.0.10
func KeyValues[T, K, V any](next func() (T, bool, error), keyExtractor func(T) K, valsExtractor func(T) []V) breakkvloop.Loop[K, V]
KeyValues transforms a loop to the key/value loop based on applying key, value extractor to the elements
func KeyValuess ¶ added in v0.0.10
func KeyValuess[T, K, V any](next func() (T, bool, error), keyExtractor func(T) (K, error), valsExtractor func(T) ([]V, error)) breakkvloop.Loop[K, V]
KeyValuess transforms a loop to the key/value loop based on applying key, value extractor to the elements
func KeysValue ¶ added in v0.0.10
func KeysValue[T, K, V any](next func() (T, bool, error), keysExtractor func(T) []K, valExtractor func(T) V) breakkvloop.Loop[K, V]
KeysValue transforms a loop to the key/value loop based on applying key, value extractor to the elements
func KeysValuee ¶ added in v0.0.10
func KeysValuee[T, K, V any](next func() (T, bool, error), keysExtractor func(T) ([]K, error), valExtractor func(T) (V, error)) breakkvloop.Loop[K, V]
KeysValuee transforms a loop to the key/value loop based on applying key, value extractor to the elements
func KeysValues ¶ added in v0.0.10
func KeysValues[T, K, V any](next func() (T, bool, error), keysExtractor func(T) ([]K, error), valsExtractor func(T) ([]V, error)) breakkvloop.Loop[K, V]
KeysValues transforms a loop to the key/value loop based on applying multiple keys, values extractor to the elements
func Map ¶ added in v0.0.14
func Map[T any, K comparable, V any](next func() (T, bool), keyExtractor func(T) K, valExtractor func(T) V) (map[K]V, error)
Map collects key\value elements into a new map by iterating over the elements
func MapResolvv ¶ added in v0.0.14
func MapResolvv[T any, K comparable, V, VR any]( next func() (T, bool, error), keyExtractor func(T) (K, error), valExtractor func(T) (V, error), resolver func(bool, K, VR, V) (VR, error), ) (m map[K]VR, err error)
MapResolvv collects key\value elements into a new map by iterating over the elements with resolving of duplicated key values
func Mapp ¶ added in v0.0.14
func Mapp[T any, K comparable, V any](next func() (T, bool, error), keyExtractor func(T) (K, error), valExtractor func(T) (V, error)) (map[K]V, error)
Mapp collects key\value elements into a new map by iterating over the elements
func Reduce ¶
Reduce reduces the elements retrieved by the 'next' function into an one using the 'merge' function. If the 'next' function returns ok=false at the first call, the zero value of 'T' type is returned.
func ReduceOK ¶ added in v0.0.13
func ReduceOK[T any](next func() (T, bool, error), merge func(T, T) T) (result T, ok bool, err error)
ReduceOK reduces the elements retrieved by the 'next' function into an one using the 'merge' function. Returns ok==false if the 'next' function returns ok=false at the first call (no more elements).
func Reducee ¶ added in v0.0.8
Reducee reduces the elements retrieved by the 'next' function into an one using the 'merge' function. If the 'next' function returns ok=false at the first call, the zero value of 'T' type is returned.
func ReduceeOK ¶ added in v0.0.13
func ReduceeOK[T any](next func() (T, bool, error), merge func(T, T) (T, error)) (result T, ok bool, err error)
ReduceeOK reduces the elements retrieved by the 'next' function into an one using the 'merge' function. Returns ok==false if the 'next' function returns ok=false at the first call (no more elements).
func SliceCap ¶ added in v0.0.8
SliceCap collects the elements retrieved by the 'next' function into a new slice with predefined capacity
Types ¶
type Loop ¶ added in v0.0.12
Loop is a function that returns the next element, ok==false if there are no more elements or an error if something is wrong.
func ConvOK ¶ added in v0.0.13
func ConvOK[From, To any](next func() (From, bool, error), converter func(from From) (to To, ok bool, err error)) Loop[To]
ConvOK creates a loop that applies the 'converter' function to iterable elements. The converter may returns converted value or ok=false to exclude the value from the loop. It may also return an error to abort the loop.
func ConvertAndFilter ¶
func ConvertAndFilter[From, To any](next func() (From, bool, error), converter func(From) (To, error), filter func(To) (bool, error)) Loop[To]
ConvertAndFilter additionally filters 'To' elements
func ConvertOK ¶ added in v0.0.13
func ConvertOK[From, To any](next func() (From, bool, error), converter func(from From) (To, bool)) Loop[To]
ConvertOK creates a loop that applies the 'converter' function to iterable elements. The converter may returns a value or ok=false to exclude the value from the loop.
func Crank ¶ added in v0.0.12
Crank rertieves a next element from the 'next' function, returns the function, element, successfully flag.
func Filt ¶
Filt creates a loop that checks elements by the 'filter' function and returns successful ones.
func FiltAndConv ¶ added in v0.0.9
func FiltAndConv[From, To any](next func() (From, bool, error), filter func(From) (bool, error), converter func(From) (To, error)) Loop[To]
FiltAndConv creates a loop that filters source elements and converts them
func FiltAndFlat ¶ added in v0.0.9
func FiltAndFlat[From, To any](next func() (From, bool, error), filter func(From) (bool, error), flattener func(From) ([]To, error)) Loop[To]
FiltAndFlat filters source elements and extracts slices of 'To' by the 'flattener' function
func FiltFlattFilt ¶ added in v0.0.9
func FiltFlattFilt[From, To any](next func() (From, bool, error), filterFrom func(From) (bool, error), flattener func(From) ([]To, error), filterTo func(To) (bool, error)) Loop[To]
FiltFlattFilt filters source elements, extracts slices of 'To' by the 'flattener' function and filters extracted elements
func Filter ¶
Filter creates a loop that checks elements by the 'filter' function and returns successful ones.
func FilterAndConvert ¶
func FilterAndConvert[From, To any](next func() (From, bool, error), filter func(From) bool, converter func(From) To) Loop[To]
FilterAndConvert creates a loop that filters source elements and converts them
func FilterAndFlat ¶ added in v0.0.9
func FilterAndFlat[From, To any](next func() (From, bool, error), filter func(From) bool, flattener func(From) []To) Loop[To]
FilterAndFlat filters source elements and extracts slices of 'To' by the 'flattener' function
func FilterConvertFilter ¶
func FilterConvertFilter[From, To any](next func() (From, bool, error), filter func(From) (bool, error), converter func(From) (To, error), filterTo func(To) (bool, error)) Loop[To]
FilterConvertFilter filters source, converts, and filters converted elements
func FilterFlatFilter ¶ added in v0.0.9
func FilterFlatFilter[From, To any](next func() (From, bool, error), filterFrom func(From) bool, flattener func(From) []To, filterTo func(To) bool) Loop[To]
FilterFlatFilter filters source elements, extracts slices of 'To' by the 'flattener' function and filters extracted elements
func FlatAndFilt ¶ added in v0.0.9
func FlatAndFilt[From, To any](next func() (From, bool, error), flattener func(From) ([]To, error), filterTo func(To) (bool, error)) Loop[To]
FlatAndFilt extracts slices of 'To' by the 'flattener' function and filters extracted elements
func Flatt ¶
func Flatt[From, To any](next func() (From, bool, error), flattener func(From) ([]To, error)) Loop[To]
Flatt converts a two-dimensional loop in an one-dimensional one.
func FlattAndFilter ¶
func FlattAndFilter[From, To any](next func() (From, bool, error), flattener func(From) []To, filterTo func(To) bool) Loop[To]
FlattAndFilter extracts slices of 'To' by the 'flattener' function and filters extracted elements
func NoNilPtrVal ¶ added in v0.0.10
NoNilPtrVal creates a loop that transform only not nil pointers to the values referenced referenced by those pointers. Nil pointers are ignored.
func PtrVal ¶ added in v0.0.10
PtrVal creates a loop that transform pointers to the values referenced by those pointers. Nil pointers are transformet to zero values.
func (Loop[T]) Accum ¶ added in v0.0.13
Accum accumulates a value by using the 'first' argument to initialize the accumulator and sequentially applying the 'merge' functon to the accumulator and each element retrieved by the 'next' function.
func (Loop[T]) Accumm ¶ added in v0.0.13
Accumm accumulates a value by using the 'first' argument to initialize the accumulator and sequentially applying the 'merge' functon to the accumulator and each element retrieved by the 'next' function.
func (Loop[T]) All ¶ added in v0.0.13
All is used to iterate through the loop using `for ... range`. Supported since go 1.22 with GOEXPERIMENT=rangefunc enabled.
func (Loop[T]) Append ¶ added in v0.0.12
Append collects the elements retrieved by the 'next' function into the specified 'out' slice
func (Loop[T]) Crank ¶ added in v0.0.12
Crank rertieves a next element from the 'next' function, returns the function, element, successfully flag.
func (Loop[T]) Filter ¶ added in v0.0.12
Filter creates a loop that checks elements by the 'filter' function and returns successful ones.
func (Loop[T]) First ¶ added in v0.0.12
First returns the first element that satisfies the condition of the 'predicate' function
func (Loop[T]) For ¶ added in v0.0.12
For applies the 'consumer' function for the elements retrieved by the 'next' function until the consumer returns the c.Break to stop.
func (Loop[T]) HasAny ¶ added in v0.0.12
HasAny finds the first element that satisfies the 'predicate' function condition and returns true if successful
func (Loop[T]) Reduce ¶ added in v0.0.12
Reduce reduces the elements retrieved by the 'next' function into an one using the 'merge' function. If the 'next' function returns ok=false at the first call, the zero value of 'T' type is returned.
func (Loop[T]) ReduceOK ¶ added in v0.0.13
ReduceOK reduces the elements retrieved by the 'next' function into an one using the 'merge' function. Returns ok==false if the 'next' function returns ok=false at the first call (no more elements).
func (Loop[T]) Reducee ¶ added in v0.0.12
Reducee reduces the elements retrieved by the 'next' function into an one using the 'merge' function. If the 'next' function returns ok=false at the first call, the zero value of 'T' type is returned.
func (Loop[T]) ReduceeOK ¶ added in v0.0.13
ReduceeOK reduces the elements retrieved by the 'next' function into an one using the 'merge' function. Returns ok==false if the 'next' function returns ok=false at the first call (no more elements).