Documentation ¶
Index ¶
- func AllMatch[T any](it Iterator[T], predicate func(T) bool) bool
- func AnyMatch[T any](it Iterator[T], predicate func(T) bool) bool
- func At[T any](it Iterator[T], index int) (T, bool)
- func Average[T constraints.Integer | constraints.Float](it Iterator[T]) float64
- func Collect[T any, S any, R any](it Iterator[T], collector Collector[S, T, R]) R
- func Contains[T comparable](it Iterator[T], target T) bool
- func Count[T any](it Iterator[T]) uint64
- func First[T any](it Iterator[T]) (T, bool)
- func Fold[T any, R any](it Iterator[T], initial R, operation func(R, T) R) R
- func ForEach[T any](it Iterator[T], action func(T))
- func IsEmpty[T any](it Iterator[T]) bool
- func IsNotEmpty[T any](it Iterator[T]) bool
- func Last[T any](it Iterator[T]) (T, bool)
- func Max[T constraints.Ordered](it Iterator[T]) (T, bool)
- func MaxBy[T any](it Iterator[T], greater cmp.LessFunc[T]) (T, bool)
- func Min[T constraints.Ordered](it Iterator[T]) (T, bool)
- func MinBy[T any](it Iterator[T], less cmp.LessFunc[T]) (T, bool)
- func NoneMatch[T any](it Iterator[T], predicate func(T) bool) bool
- func Product[T constraints.Integer | constraints.Float](it Iterator[T]) T
- func Reduce[T any](it Iterator[T], operation func(T, T) T) (T, bool)
- func Sum[T constraints.Integer | constraints.Float](it Iterator[T]) T
- func ToMap[K comparable, V any](it Iterator[*types.Pair[K, V]]) map[K]V
- func ToSlice[T any](it Iterator[T]) []T
- func Unzip[A any, B any](it Iterator[*types.Pair[A, B]]) ([]A, []B)
- type BiFunction
- type BinaryOperator
- type Collector
- type Comparator
- type Consumer
- type Function
- type IterStream
- func (it *IterStream[T]) All(f func(T) bool) bool
- func (it *IterStream[T]) Any(f func(T) bool) bool
- func (it *IterStream[T]) Count() uint64
- func (it *IterStream[T]) Filter(f func(T) bool) *IterStream[T]
- func (it *IterStream[T]) Fold(initVal T, operation func(T, T) T) T
- func (it *IterStream[T]) ForEach(f func(T))
- func (it *IterStream[T]) Limit(n int) *IterStream[T]
- func (it *IterStream[T]) Map(transform func(T) T) *IterStream[T]
- func (it *IterStream[T]) None(f func(T) bool) bool
- func (it *IterStream[T]) Reduce(operation func(T, T) T) (T, bool)
- func (it *IterStream[T]) Skip(n int) *IterStream[T]
- type Iterable
- type Iterator
- func Concat[T any](left Iterator[T], right Iterator[T]) Iterator[T]
- func Enumerate[T any](it Iterator[T]) Iterator[*types.Pair[int, T]]
- func Filter[T any](it Iterator[T], predicate func(T) bool) Iterator[T]
- func Flatten[T Iterable[U], U any](it Iterator[T]) Iterator[U]
- func Limit[T any](it Iterator[T], count int) Iterator[T]
- func Map[T any, R any](it Iterator[T], transform func(T) R) Iterator[R]
- func Range[T constraints.Integer](begin, end, step T) Iterator[T]
- func Skip[T any](it Iterator[T], count int) Iterator[T]
- func Slice[S ~[]T, T any](source S) Iterator[T]
- func Step[T any](it Iterator[T], count int) Iterator[T]
- func String(input string) Iterator[rune]
- func Zip[T any, U any](left Iterator[T], right Iterator[U]) Iterator[*types.Pair[T, U]]
- type Predicate
- type Stream
- type Supplier
- type UnaryOperator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Average ¶
func Average[T constraints.Integer | constraints.Float](it Iterator[T]) float64
Returns the average of all the elements in the iterator.
func Contains ¶
func Contains[T comparable](it Iterator[T], target T) bool
Returns true if the target is included in the iterator.
func ForEach ¶
The action is executed for each element of the iterator, and the argument to the action is the element.
func IsNotEmpty ¶
Ruturns true if the count of Iterator is 0.
func Max ¶
func Max[T constraints.Ordered](it Iterator[T]) (T, bool)
Return the maximum value of all elements of the iterator.
func Min ¶
func Min[T constraints.Ordered](it Iterator[T]) (T, bool)
Return the minimum value of all elements of the iterator.
func Product ¶
func Product[T constraints.Integer | constraints.Float](it Iterator[T]) T
Returns the product of all the elements in the iterator.
func Sum ¶
func Sum[T constraints.Integer | constraints.Float](it Iterator[T]) T
Returns the sum of all the elements in the iterator.
Types ¶
type BinaryOperator ¶
type BinaryOperator[T any] func(T, T) T
BinaryOperator 输入两个相同类型的参数,对其做二元运算,返回相同类型的结果
type Comparator ¶
Comparator 比较两个元素. 第一个元素大于第二个元素时,返回正数; 第一个元素小于第二个元素时,返回负数; 否则返回 0.
type IterStream ¶
type IterStream[T any] struct { // contains filtered or unexported fields }
func SliceStreamOf ¶
func SliceStreamOf[S ~[]T, T any](source S) *IterStream[T]
func StreamOf ¶
func StreamOf[T any](iter Iterator[T]) *IterStream[T]
func (*IterStream[T]) All ¶
func (it *IterStream[T]) All(f func(T) bool) bool
func (*IterStream[T]) Any ¶
func (it *IterStream[T]) Any(f func(T) bool) bool
func (*IterStream[T]) Count ¶
func (it *IterStream[T]) Count() uint64
func (*IterStream[T]) Filter ¶
func (it *IterStream[T]) Filter(f func(T) bool) *IterStream[T]
func (*IterStream[T]) Fold ¶
func (it *IterStream[T]) Fold(initVal T, operation func(T, T) T) T
func (*IterStream[T]) ForEach ¶
func (it *IterStream[T]) ForEach(f func(T))
func (*IterStream[T]) Limit ¶
func (it *IterStream[T]) Limit(n int) *IterStream[T]
func (*IterStream[T]) Map ¶
func (it *IterStream[T]) Map(transform func(T) T) *IterStream[T]
func (*IterStream[T]) None ¶
func (it *IterStream[T]) None(f func(T) bool) bool
func (*IterStream[T]) Reduce ¶
func (it *IterStream[T]) Reduce(operation func(T, T) T) (T, bool)
func (*IterStream[T]) Skip ¶
func (it *IterStream[T]) Skip(n int) *IterStream[T]
type Iterator ¶
func Concat ¶
By connecting two iterators in series, the new iterator will iterate over the first iterator before continuing with the second iterator.
func Range ¶
func Range[T constraints.Integer](begin, end, step T) Iterator[T]
RangeIterOf returns an Iterator over a range of integers.
func Step ¶
Converts an iterator to another iterator that skips a specified number of times each time.
type Stream ¶
type Stream[T any] interface { Filter(Predicate[T]) Stream[T] Map(Function[T, T]) Stream[T] //同类型转换,没啥意义 FlatMap(Function[T, Iterator[T]]) Stream[T] //同Map Peek(Consumer[T]) Stream[T] Fold(initVal T, acc BinaryOperator[T]) Zip(Iterator[T], Iterator[T]) Stream[T] Distinct(Function[T, int]) Stream[T] Sorted(Comparator[T]) Stream[T] Limit(int64) Stream[T] Skip(int64) Stream[T] ForEach(Consumer[T]) Collect() []T All(Predicate[T]) bool None(Predicate[T]) bool Any(Predicate[T]) bool Reduce(acc BinaryOperator[T]) (T, bool) ReduceFrom(initVal T, acc BinaryOperator[T]) T First() (T, bool) Count() int64 }