Documentation ¶
Index ¶
- func AllMatch[T any](predicate func(T) bool, it Iterator[T]) bool
- func AnyMatch[T any](predicate func(T) bool, it Iterator[T]) bool
- func At[T any](index int, it Iterator[T]) (T, bool)
- func Average[T constraints.Integer | constraints.Float](it Iterator[T]) float64
- func Collect[T any, S any, R any](collector Collector[S, T, R], it Iterator[T]) R
- func CollectToMap[K comparable, V any](it Iterator[types.Pair[K, V]]) map[K]V
- func Contains[T comparable](target T, it Iterator[T]) bool
- func Count[T any](it Iterator[T]) int
- func First[T any](it Iterator[T]) (T, bool)
- func Fold[T any, R any](initial R, operation func(R, T) R, it Iterator[T]) R
- func ForEach[T any](action func(T), it Iterator[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](greater func(T, T) bool, it Iterator[T]) (T, bool)
- func Min[T constraints.Ordered](it Iterator[T]) (T, bool)
- func MinBy[T any](less func(T, T) bool, it Iterator[T]) (T, bool)
- func NoneMatch[T any](predicate func(T) bool, it Iterator[T]) bool
- func Product[T constraints.Integer | constraints.Float](it Iterator[T]) T
- func Reduce[T any](operation func(T, T) T, it Iterator[T]) (T, bool)
- func Sum[T constraints.Integer | constraints.Float](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 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](predicate func(T) bool, it Iterator[T]) Iterator[T]
- func Flatten[T Iterable[U], U any](it Iterator[T]) Iterator[U]
- func Limit[T any](count int, it Iterator[T]) Iterator[T]
- func Map[T any, R any](transform func(T) R, it Iterator[T]) Iterator[R]
- func RangeOf[T constraints.Integer](begin, end, step T) Iterator[T]
- func Skip[T any](count int, it Iterator[T]) Iterator[T]
- func Step[T any](count int, it Iterator[T]) Iterator[T]
- func StringOf(input string) Iterator[rune]
- func Zip[T any, U any](left Iterator[T], right Iterator[U]) Iterator[*types.Pair[T, U]]
- type Predicate
- type Range
- type Slice
- type Stream
- type String
- 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 CollectToMap ¶
func CollectToMap[K comparable, V any](it Iterator[types.Pair[K, V]]) map[K]V
Collect to built-in map.
func Contains ¶
func Contains[T comparable](target T, it Iterator[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 ¶ added in v1.6.4
type BinaryOperator[T any] func(T, T) T
BinaryOperator 输入两个相同类型的参数,对其做二元运算,返回相同类型的结果
type Comparator ¶ added in v1.6.4
Comparator 比较两个元素. 第一个元素大于第二个元素时,返回正数; 第一个元素小于第二个元素时,返回负数; 否则返回 0.
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 RangeOf ¶
func RangeOf[T constraints.Integer](begin, end, step T) Iterator[T]
Range 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 Range ¶
type Range[T constraints.Integer] struct { Begin T End T }
type Stream ¶ added in v1.6.4
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 }
type UnaryOperator ¶ added in v1.6.4
type UnaryOperator[T any] func(T) T
UnaryOperator 对输入进行一元运算返回相同类型的结果