Documentation ¶
Index ¶
- type Stream
- func Concat[T any](a, b Stream[T]) Stream[T]
- func FromChannel[T any](source <-chan T) Stream[T]
- func FromRange[T constraints.Integer | constraints.Float](start, end, step T) Stream[T]
- func FromSlice[T any](source []T) Stream[T]
- func Generate[T any](generator func() func() (item T, ok bool)) Stream[T]
- func Of[T any](elems ...T) Stream[T]
- func (s Stream[T]) AllMatch(predicate func(item T) bool) bool
- func (s Stream[T]) AnyMatch(predicate func(item T) bool) bool
- func (s Stream[T]) Count() int
- func (s Stream[T]) Distinct() Stream[T]
- func (s Stream[T]) Filter(predicate func(item T) bool) Stream[T]
- func (s Stream[T]) FindFirst() (T, bool)
- func (s Stream[T]) FindLast() (T, bool)
- func (s Stream[T]) ForEach(action func(item T))
- func (s Stream[T]) Limit(maxSize int) Stream[T]
- func (s Stream[T]) Map(mapper func(item T) T) Stream[T]
- func (s Stream[T]) Max(less func(a, b T) bool) (T, bool)
- func (s Stream[T]) Min(less func(a, b T) bool) (T, bool)
- func (s Stream[T]) NoneMatch(predicate func(item T) bool) bool
- func (s Stream[T]) Peek(consumer func(item T)) Stream[T]
- func (s Stream[T]) Range(start, end int) Stream[T]
- func (s Stream[T]) Reduce(initial T, accumulator func(a, b T) T) T
- func (s Stream[T]) Reverse() Stream[T]
- func (s Stream[T]) Skip(n int) Stream[T]
- func (s Stream[T]) Sorted(less func(a, b T) bool) Stream[T]
- func (s Stream[T]) ToSlice() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stream ¶
type Stream[T any] struct { // contains filtered or unexported fields }
func Concat ¶
Concat creates a lazily concatenated Stream whose elements are all the elements of the first Stream followed by all the elements of the second Stream.
func FromChannel ¶
FromChannel creates Stream from channel.
func FromRange ¶
func FromRange[T constraints.Integer | constraints.Float](start, end, step T) Stream[T]
FromRange creates a number Stream from start to end. both start and end are included. [start, end]
func (Stream[T]) AllMatch ¶
AllMatch returns whether all elements of this Stream match the provided predicate.
func (Stream[T]) AnyMatch ¶
AnyMatch returns whether any elements of this Stream match the provided predicate.
func (Stream[T]) Filter ¶
Filter returns a Stream consisting of the elements of this Stream that match the given predicate.
func (Stream[T]) FindFirst ¶
FindFirst returns the first element of this Stream and true, or zero value and false if the Stream is empty.
func (Stream[T]) FindLast ¶
FindLast returns the last element of this Stream and true, or zero value and false if the Stream is empty.
func (Stream[T]) ForEach ¶
func (s Stream[T]) ForEach(action func(item T))
ForEach performs an action for each element of this Stream.
func (Stream[T]) Limit ¶
Limit returns a Stream consisting of the elements of this Stream, truncated to be no longer than maxSize in length.
func (Stream[T]) Map ¶
Map returns a Stream consisting of the elements of this Stream that apply the given function to elements of Stream.
func (Stream[T]) Max ¶
Max returns the maximum element of this Stream according to the provided less function. less: a > b
func (Stream[T]) Min ¶
Min returns the minimum element of this Stream according to the provided less function. less: a < b
func (Stream[T]) NoneMatch ¶
NoneMatch returns whether no elements of this Stream match the provided predicate.
func (Stream[T]) Peek ¶
Peek returns a Stream consisting of the elements of this Stream, additionally performing the provided action on each element as elements are consumed from the resulting Stream.
func (Stream[T]) Range ¶
Range returns a Stream whose elements are in the range from start(included) to end(excluded) original Stream.
func (Stream[T]) Reduce ¶
func (s Stream[T]) Reduce(initial T, accumulator func(a, b T) T) T
Reduce performs a reduction on the elements of this Stream, using an associative accumulation function, and returns an Optional describing the reduced value, if any.
func (Stream[T]) Reverse ¶
Reverse returns a Stream whose elements are reverse order of given Stream.
func (Stream[T]) Skip ¶
Skip returns a Stream consisting of the remaining elements of this Stream after discarding the first n elements of the Stream. If this Stream contains fewer than n elements then an empty Stream will be returned.