Documentation
¶
Index ¶
- type Comparator
- type Stream
- func (s Stream) AllMatch(predicate func(e types.T) bool) bool
- func (s Stream) AnyMatch(predicate func(e types.T) bool) bool
- func (s Stream) Count() int
- func (s Stream) Distinct(distinctFn func(item types.T) types.R) Stream
- func (s Stream) DropWhile(predicate func(t types.T) bool) Stream
- func (s Stream) Filter(predicate func(e types.T) bool) Stream
- func (s Stream) FindFirst() types.T
- func (s Stream) FindLast() types.T
- func (s Stream) FlatMap(mapper func(t types.T) Stream) Stream
- func (s Stream) ForEach(action func(e types.T))
- func (s Stream) GroupingBy(classifier func(t types.T) types.K) map[types.K][]types.T
- func (s Stream) Limit(maxSize int) Stream
- func (s Stream) Map(mapper func(e types.T) (r types.R)) Stream
- func (s Stream) Max(compare func(first types.T, second types.T) int) types.T
- func (s Stream) Min(compare func(first types.T, second types.T) int) types.T
- func (s Stream) NoneMatch(predicate func(e types.T) bool) bool
- func (s Stream) Parallel(workers int) Stream
- func (s Stream) Peek(consumer func(e types.T)) Stream
- func (s Stream) Reduce(accumulator func(e1 types.T, e2 types.T) types.T) types.T
- func (s Stream) ReduceFromIdentity(identity types.T, accumulator func(e1 types.T, e2 types.T) types.T) types.T
- func (s Stream) Skip(n int) Stream
- func (s Stream) Sorted(compare func(first types.T, second types.T) int) Stream
- func (s Stream) TakeWhile(predicate func(t types.T) bool) Stream
- func (s Stream) ToMap(keyMapper func(t types.T) types.K, valueMapper func(t types.T) types.R) map[types.K]types.R
- func (s Stream) ToSlice() []types.T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparator ¶
type Comparator struct {
// contains filtered or unexported fields
}
func (*Comparator) Len ¶
func (c *Comparator) Len() int
func (*Comparator) Less ¶
func (c *Comparator) Less(i, j int) bool
func (*Comparator) Swap ¶
func (c *Comparator) Swap(i, j int)
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a sequence of elements supporting sequential and parallel aggregate operations. Stream operations are combined into a stream pipeline, and computational processing is performed during terminal operation. Stream consists of a source(OfElements OfSlice OfMap Generate), zero or more intermediate operations(Filter Map Peek FlatMap Distinct Sorted Skip Limit TakeWhile DropWhile), and terminal operations(ForEach FindLast FindFirst Reduce ReduceFromIdentity Count Max Min ToSlice ToMap GroupingBy AllMatch AnyMatch NoneMatch FindFirst). Stream has lazy evaluation and short-circuit evaluation. Example See: _example/example.go
func Generate ¶
Generate Return an infinite sequential Stream,elements are generated by the supplier.
func OfElements ¶
OfElements Return a sequential Stream containing elements.
func (Stream) AllMatch ¶
AllMatch Returns whether all elements of this Stream match the predicate function.
func (Stream) AnyMatch ¶
AnyMatch Returns whether any elements of this Stream match the predicate function.
func (Stream) Distinct ¶
Distinct Returns a Stream consisting of the distinct elements,confirm the uniqueness of the element through the distinctFn
func (Stream) DropWhile ¶
DropWhile When the element matching function, start passing the element to Stream.
func (Stream) Filter ¶
Filter Returns a Stream consisting of the elements of this stream that match the given predicate function.
func (Stream) FlatMap ¶
FlatMap Returns a Stream consisting of the results of replacing each element of this Stream with the contents of a mapped Stream produced by applying the provided mapper function to each element.
func (Stream) GroupingBy ¶
GroupingBy Returns a Map containing all elements of the Stream transformed by the classifier function.
func (Stream) Limit ¶
Limit Returns a stream consisting of the elements of this Stream, truncated to be no longer than maxSize in length.
func (Stream) NoneMatch ¶
NoneMatch Returns whether any elements of this Stream non match the predicate function.
func (Stream) Parallel ¶
Parallel Set the number of workers to perform Stream operations in parallel.
func (Stream) Peek ¶
Peek Does not transform the Stream, executes the consumer function on the elements in the Stream.
func (Stream) Reduce ¶
Reduce Performs a reduction on the elements of this Stream, using the associative accumulator function, and returns the reduced value.
func (Stream) ReduceFromIdentity ¶
func (s Stream) ReduceFromIdentity(identity types.T, accumulator func(e1 types.T, e2 types.T) types.T) types.T
ReduceFromIdentity Performs a reduction on the elements of this Stream, using the provided identity value and an associative accumulator function, and returns the reduced value.
func (Stream) Skip ¶
Skip Discard the previous n elements, return the Stream of the remaining elements.
func (Stream) Sorted ¶
Sorted Return to orderly Stream. sort elements in Stream based on compare function.