Documentation ¶
Overview ¶
Package stream provides a stream implementation and helper functions
Index ¶
- type Iter
- func (t Iter[T]) Conv(converter func(T) (T, error)) Iter[T]
- func (t Iter[T]) Convert(converter func(T) T) Iter[T]
- func (t Iter[T]) Filt(predicate func(T) (bool, error)) Iter[T]
- func (t Iter[T]) Filter(predicate func(T) bool) Iter[T]
- func (t Iter[T]) First(predicate func(T) (bool, error)) (T, bool, error)
- func (t Iter[T]) For(walker func(T) error) error
- func (t Iter[T]) HasAny(predicate func(T) (bool, error)) (bool, error)
- func (t Iter[T]) Iter() Iter[T]
- func (t Iter[T]) Next() (element T, ok bool, err error)
- func (t Iter[T]) Reduce(merger func(T, T) (T, error)) (T, error)
- func (t Iter[T]) Slice() ([]T, error)
- type Stream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iter ¶
type Iter[T any] struct { // contains filtered or unexported fields }
Iter is the Iterator based stream implementation.
func (Iter[T]) Conv ¶
Conv returns a breakable stream that applies the 'converter' function to the collection elements
func (Iter[T]) Convert ¶
Convert returns a stream that applies the 'converter' function to the collection elements
func (Iter[T]) Filt ¶
Filt returns a breakable stream consisting of elements that satisfy the condition of the 'predicate' function
func (Iter[T]) Filter ¶
Filter returns a stream consisting of elements that satisfy the condition of the 'predicate' function
func (Iter[T]) First ¶
First returns the first element that satisfies the condition of the 'predicate' function
func (Iter[T]) For ¶
For applies the 'walker' function for the elements. Return the c.ErrBreak to stop.
func (Iter[T]) HasAny ¶
HasAny finds the first element that satisfies the 'predicate' function condition and returns true if successful
type Stream ¶
type Stream[T, I any] interface { c.Iterator[T] Iter() I Slice() ([]T, error) Reduce(merger func(T, T) (T, error)) (T, error) HasAny(predicate func(T) (bool, error)) (bool, error) }
Stream is collection or stream of elements in transformation state. It supports interrupting on an error that may occur in intermediate or final executor functions.