slice

package
v1.2.116 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

A sequence of elements supporting sequential and parallel aggregate operations. The following example illustrates an aggregate operation using SEE java/util/stream/Stream.java

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllMatchFunc

func AllMatchFunc(s interface{}, f func(interface{}) bool) bool

AllMatchFunc returns whether all elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then {@code true} is returned and the predicate is not evaluated.

func AnyMatchFunc

func AnyMatchFunc(s interface{}, f func(interface{}) bool) bool

AnyMatchFunc returns whether any elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then {@code false} is returned and the predicate is not evaluated.

func ConcatFunc

func ConcatFunc(s1, s2 interface{}) interface{}

ConcatFunc creates a lazily concatenated stream whose elements are all the elements of the first stream followed by all the elements of the second stream. The resulting stream is ordered if both of the input streams are ordered, and parallel if either of the input streams is parallel. When the resulting stream is closed, the close handlers for both input streams are invoked.

func CountFunc

func CountFunc(s interface{}) int

CountFunc returns the maximum element of this stream according to the provided.

func DistinctFunc

func DistinctFunc(s interface{}, f func(interface{}, interface{}) int) interface{}

DistinctFunc returns a slice consisting of the distinct elements (according to {@link Object#equals(Object)}) of this slice.

func DropUntilFunc

func DropUntilFunc(s interface{}, f func(interface{}) bool) interface{}

DropUntilFunc returns, if this slice is ordered, a slice consisting of the remaining elements of this slice after dropping the longest prefix of elements that match the given predicate. Otherwise returns, if this slice is unordered, a slice consisting of the remaining elements of this slice after dropping a subset of elements that match the given predicate.

func DropWhileFunc

func DropWhileFunc(s interface{}, f func(interface{}) bool) interface{}

DropWhileFunc returns, if this slice is ordered, a slice consisting of the remaining elements of this slice after dropping the longest prefix of elements that match the given predicate. Otherwise returns, if this slice is unordered, a slice consisting of the remaining elements of this slice after dropping a subset of elements that match the given predicate.

func EmptyFunc

func EmptyFunc(s interface{}) interface{}

EmptyFunc returns an empty sequential {@code slice}.

func FilterFunc

func FilterFunc(s interface{}, f func(interface{}) bool) interface{}

FilterFunc returns a slice consisting of the elements of this slice that match the given predicate.

func FindAnyFunc

func FindAnyFunc(s interface{}, f func(interface{}) bool) interface{}

FindAnyFunc returns an {@link Optional} describing some element of the stream, or an empty {@code Optional} if the stream is empty.

func FindAnyIndexFunc

func FindAnyIndexFunc(s interface{}, f func(interface{}) bool) int

FindAnyFunc returns an {@link interface{}} describing some element of the stream, or an empty {@code Optional} if the stream is empty.

func FindFirstFunc

func FindFirstFunc(s interface{}, f func(interface{}) bool) interface{}

FindFirstFunc returns an {@link Optional} describing the first element of this stream, or an empty {@code Optional} if the stream is empty. If the stream has no encounter order, then any element may be returned.

func FindFirstIndexFunc

func FindFirstIndexFunc(s interface{}, f func(interface{}) bool) int

FindFirstFunc returns an {@link Optional} describing the first index of this stream, or an empty {@code Optional} if the stream is empty. If the stream has no encounter order, then any element may be returned.

func ForEachFunc

func ForEachFunc(s interface{}, f func(interface{}))

ForEachFunc Performs an action for each element of this slice. <p>The behavior of this operation is explicitly nondeterministic. For parallel slice pipelines, this operation does <em>not</em> guarantee to respect the encounter order of the slice, as doing so would sacrifice the benefit of parallelism. For any given element, the action may be performed at whatever time and in whatever thread the library chooses. If the action accesses shared state, it is responsible for providing the required synchronization.

func ForEachOrderedFunc

func ForEachOrderedFunc(s interface{}, f func(interface{}))

ForEachOrderedFunc Performs an action for each element of this slice. <p>This operation processes the elements one at a time, in encounter order if one exists. Performing the action for one element performing the action for subsequent elements, but for any given element, the action may be performed in whatever thread the library chooses.

func LimitFunc

func LimitFunc(s interface{}, maxSize int) interface{}

LimitFunc Returns a slice consisting of the elements of this slice, truncated to be no longer than {@code maxSize} in length.

func MapFunc

func MapFunc(s interface{}, f func(interface{}) interface{}) interface{}

MapFunc returns a slice consisting of the results of applying the given function to the elements of this slice.

func MaxFunc

func MaxFunc(s interface{}, f func(interface{}, interface{}) int) interface{}

MaxFunc returns the maximum element of this stream according to the provided.

func MinFunc

func MinFunc(s interface{}, f func(interface{}, interface{}) int) interface{}

MinFunc returns the minimum element of this stream according to the provided.

func NoneMatchFunc

func NoneMatchFunc(s interface{}, f func(interface{}) bool) bool

NoneMatchFunc returns whether no elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then {@code true} is returned and the predicate is not evaluated.

func Of

func Of(obj interface{}) []interface{}

Of returns a slice consisting of the elements. obj: Accept Array、Slice、String(as []byte if ifStringAsRune else []rune)

func PeekFunc

func PeekFunc(s interface{}, f func(interface{})) interface{}

PeekFunc returns a slice consisting of the elements of this slice, additionally performing the provided action on each element as elements are consumed from the resulting slice.

func ReduceFunc

func ReduceFunc(s interface{}, f func(left, right interface{}) interface{}) interface{}

ReduceFunc calls a defined callback function on each element of an array, and returns an array that contains the results.

func SkipFunc

func SkipFunc(s interface{}, n int) interface{}

SkipFunc returns a slice consisting of the remaining elements of this slice after discarding the first {@code n} elements of the slice. If this slice contains fewer than {@code n} elements then an empty slice will be returned.

func SortedFunc

func SortedFunc(s interface{}, f func(interface{}, interface{}) int) interface{}

SortedFunc returns a slice consisting of the distinct elements (according to {@link Object#equals(Object)}) of this slice. s: Accept Array、Slice、String(as []byte if ifStringAsRune else []rune)

func TakeUntilFunc

func TakeUntilFunc(s interface{}, f func(interface{}) bool) interface{}

TakeUntilFunc returns, if this slice is ordered, a slice consisting of the longest prefix of elements taken from this slice that unmatch the given predicate. Otherwise returns, if this slice is unordered, a slice consisting of a subset of elements taken from this slice that unmatch the given predicate.

func TakeWhileFunc

func TakeWhileFunc(s interface{}, f func(interface{}) bool) interface{}

TakeWhileFunc returns, if this slice is ordered, a slice consisting of the longest prefix of elements taken from this slice that match the given predicate. Otherwise returns, if this slice is unordered, a slice consisting of a subset of elements taken from this slice that match the given predicate.

func ToSliceFunc

func ToSliceFunc(s interface{}) interface{}

ToSliceFunc returns an array containing the elements of this stream.

Types

type MapPair

type MapPair struct {
	Key   interface{}
	Value interface{}
}

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

func NewStream

func NewStream() *Stream

func (*Stream) AllMatch

func (stream *Stream) AllMatch(f func(interface{}) bool) bool

func (*Stream) AnyMatch

func (stream *Stream) AnyMatch(f func(interface{}) bool) bool

func (*Stream) Concat

func (stream *Stream) Concat(s2 *Stream) *Stream

func (*Stream) ConcatWithValue

func (stream *Stream) ConcatWithValue(v interface{}) *Stream

func (*Stream) Count

func (stream *Stream) Count(ifStringAsRune ...bool) int

func (*Stream) Distinct

func (stream *Stream) Distinct(f func(interface{}, interface{}) int) *Stream

func (*Stream) DropUntil

func (stream *Stream) DropUntil(f func(interface{}) bool) *Stream

func (*Stream) DropWhile

func (stream *Stream) DropWhile(f func(interface{}) bool) *Stream

func (*Stream) Empty

func (stream *Stream) Empty(ifStringAsRune ...bool) interface{}

func (*Stream) Filter

func (stream *Stream) Filter(f func(interface{}) bool) *Stream

func (*Stream) FindAny

func (stream *Stream) FindAny(f func(interface{}) bool) optional.Optional

func (*Stream) FindAnyIndex

func (stream *Stream) FindAnyIndex(f func(interface{}) bool) int

func (*Stream) FindFirst

func (stream *Stream) FindFirst(f func(interface{}) bool) optional.Optional

func (*Stream) FindFirstIndex

func (stream *Stream) FindFirstIndex(f func(interface{}) bool) int

func (*Stream) ForEach

func (stream *Stream) ForEach(f func(interface{}))

func (*Stream) ForEachOrdered

func (stream *Stream) ForEachOrdered(f func(interface{}))

func (*Stream) Length

func (stream *Stream) Length() int

func (*Stream) Limit

func (stream *Stream) Limit(maxSize int) *Stream

func (*Stream) Map

func (stream *Stream) Map(f func(interface{}) interface{}) *Stream

func (*Stream) Max

func (stream *Stream) Max(f func(interface{}, interface{}) int) optional.Optional

func (*Stream) Min

func (stream *Stream) Min(f func(interface{}, interface{}) int) optional.Optional

func (*Stream) NoneMatch

func (stream *Stream) NoneMatch(f func(interface{}) bool) bool

func (*Stream) Of

func (stream *Stream) Of(ifStringAsRune ...bool) *Stream

func (*Stream) Peek

func (stream *Stream) Peek(f func(interface{})) *Stream

func (*Stream) Reduce

func (stream *Stream) Reduce(f func(left, right interface{}) interface{}) optional.Optional

func (*Stream) Size

func (stream *Stream) Size() int

Size grammar sugar for count

func (*Stream) Skip

func (stream *Stream) Skip(n int) *Stream

func (*Stream) Sorted

func (stream *Stream) Sorted(f func(interface{}, interface{}) int) *Stream

func (*Stream) TakeUntil

func (stream *Stream) TakeUntil(f func(interface{}) bool) *Stream

func (*Stream) TakeWhile

func (stream *Stream) TakeWhile(f func(interface{}) bool) *Stream

func (*Stream) ToSlice

func (stream *Stream) ToSlice(ifStringAsRune ...bool) interface{}

func (*Stream) Value

func (stream *Stream) Value() interface{}

func (*Stream) WithSlice

func (stream *Stream) WithSlice(s interface{}) *Stream

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL