Documentation ¶
Index ¶
- func AllMatch[T any](seq iter.Seq[T], test types.Predicate[T]) bool
- func AnyMatch[T any](seq iter.Seq[T], test types.Predicate[T]) bool
- func At[T any](it iter.Seq[T], index int) (T, bool)
- func Average[T constraintsi.Number](it iter.Seq[T]) T
- func Chain[T any](seqs ...iter.Seq[T]) iter.Seq[T]
- func ChannelAll2[C ~chan T, T any](c C) iter.Seq2[int, T]
- func Collect[T any, S any, R any](it iter.Seq[T], collector interfaces.Collector[S, T, R]) R
- func Contains[T comparable](it iter.Seq[T], target T) bool
- func Count[T any](seq iter.Seq[T]) (count int)
- func Distinct[T any, C comparable](seq iter.Seq[T], f types.UnaryFunction[T, C]) iter.Seq[T]
- func Enumerate[T any](seq iter.Seq[T]) iter.Seq[types.Pair[int, T]]
- func Every[T any](seq iter.Seq[T], test types.Predicate[T]) bool
- func Filter[T any](seq iter.Seq[T], test types.Predicate[T]) iter.Seq[T]
- func First[T any](seq iter.Seq[T]) (T, bool)
- func FlatMap[T, R any](seq iter.Seq[T], flatten types.UnaryFunction[T, iter.Seq[R]]) iter.Seq[R]
- func Fold[T, R any](seq iter.Seq[T], initVal R, acc types.BinaryFunction[R, T, R]) (result R)
- func ForEach[T any](seq iter.Seq[T], accept types.Consumer[T])
- func IsEmpty[T any](it iter.Seq[T]) bool
- func IsNotEmpty[T any](it iter.Seq[T]) bool
- func IsSorted[T any](seq iter.Seq[T], cmp types.Comparator[T]) bool
- func IterSeq[T any](iter Iterator[T]) iter2.Seq[T]
- func JoinBy[T any](it iter.Seq[T], toString func(T) string, sep string) string
- func Last[T any](it iter.Seq[T]) (T, bool)
- func Limit[T any](seq iter.Seq[T], limit int) iter.Seq[T]
- func Map[T, R any](seq iter.Seq[T], f types.UnaryFunction[T, R]) iter.Seq[R]
- func Max[T constraints.Ordered](it iter.Seq[T]) (T, bool)
- func MaxBy[T any](it iter.Seq[T], greater cmp.LessFunc[T]) (T, bool)
- func Mean[T constraintsi.Number](seq iter.Seq[T]) float64
- func Merge[T any](iters ...iter.Seq[T]) iter.Seq[T]
- func Min[T constraints.Ordered](it iter.Seq[T]) (T, bool)
- func Operator[T any](seq iter.Seq[T], add types.BinaryOperator[T]) T
- func OperatorBy[T any](it iter.Seq[T], f types.BinaryOperator[T]) T
- func Peek[T any](seq iter.Seq[T], accept types.Consumer[T]) iter.Seq[T]
- func Product[T constraintsi.Number](it iter.Seq[T]) T
- func RangeAll2[T constraintsi.Number](begin, end, step T) iter.Seq2[int, T]
- func Reduce[T any](seq iter.Seq[T], acc types.BinaryOperator[T]) (T, bool)
- func Seq2Keys[K, V any](s iter.Seq2[K, V]) iter.Seq[K]
- func Seq2Seq[K, V any](s iter.Seq2[K, V]) iter.Seq[types.Pair[K, V]]
- func Seq2Values[K, V any](s iter.Seq2[K, V]) iter.Seq[V]
- func SeqSeq2[T any](seq iter.Seq[T]) iter.Seq2[int, T]
- func Skip[T any](seq iter.Seq[T], skip int) iter.Seq[T]
- func Some[T any](seq iter.Seq[T], test types.Predicate[T]) bool
- func Sorted[T any](it iter.Seq[T], cmp types.Comparator[T]) iter.Seq[T]
- func StringAll2[T ~string](input T) iter.Seq2[int, rune]
- func Sum[T constraintsi.Number](it iter.Seq[T]) T
- func SumComparable[T constraints.Ordered](seq iter.Seq[T]) T
- func SumCount[T constraintsi.Number](it iter.Seq[T]) (T, int)
- func ToMap[K comparable, V any](it iter.Seq[types.Pair[K, V]]) map[K]V
- func ToSlice[V any](it iter.Seq[V]) []V
- func Until[T any](seq iter.Seq[T], match types.Predicate[T]) iter.Seq[T]
- func UntilComparable[T comparable](seq iter.Seq[T], e T) iter.Seq[T]
- func Unzip[A any, B any](it iter.Seq[types.Pair[A, B]]) ([]A, []B)
- type GoIter
- type Iterable
- type Iterator
- type Seq
- func ChannelAll[C ~chan T, T any](c C) Seq[T]
- func HashMapAll[M ~map[K]V, K comparable, V any](m M) Seq[types.Pair[K, V]]
- func RangeAll[T constraintsi.Number](begin, end, step T) Seq[T]
- func SliceAll[S ~[]T, T any](input S) Seq[types.Pair[int, T]]
- func SliceAllValues[S ~[]T, T any](input S) Seq[T]
- func SliceBackward[S ~[]T, T any](input S) Seq[types.Pair[int, T]]
- func SliceBackwardValues[S ~[]T, T any](input S) Seq[T]
- func StringAll[T ~string](input T) Seq[types.Pair[int, rune]]
- func StringRunes[T ~string](input T) Seq[rune]
- func (it Seq[T]) All(test types.Predicate[T]) bool
- func (it Seq[T]) Any(test types.Predicate[T]) bool
- func (it Seq[T]) Collect() []T
- func (it Seq[T]) Count() int
- func (it Seq[T]) Distinct(f types.UnaryFunction[T, int]) Stream[T]
- func (it Seq[T]) Filter(test types.Predicate[T]) Stream[T]
- func (it Seq[T]) First() (T, bool)
- func (it Seq[T]) FlatMap(f types.UnaryFunction[T, iter.Seq[T]]) Stream[T]
- func (it Seq[T]) Fold(initVal T, acc types.BinaryOperator[T]) T
- func (it Seq[T]) ForEach(accept types.Consumer[T])
- func (it Seq[T]) IsSorted(cmp types.Comparator[T]) bool
- func (it Seq[T]) Iter() Iterator[T]
- func (it Seq[T]) Limit(limit int) Stream[T]
- func (it Seq[T]) Map(f types.UnaryFunction[T, T]) Stream[T]
- func (it Seq[T]) Peek(accept types.Consumer[T]) Stream[T]
- func (it Seq[T]) Reduce(acc types.BinaryOperator[T]) (T, bool)
- func (it Seq[T]) Seq() iter.Seq[T]
- func (it Seq[T]) Skip(skip int) Stream[T]
- func (it Seq[T]) Sorted(cmp types.Comparator[T]) Stream[T]
- func (it Seq[T]) Sum(add types.BinaryOperator[T]) T
- func (it Seq[T]) Until(test types.Predicate[T]) Stream[T]
- type Stream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllMatch ¶ added in v0.1.0
AllMatch test if every element are all match the Predicate. 是否每个元素都满足条件 == Every
func AnyMatch ¶ added in v0.1.0
AnyMatch test if any element matches the Predicate. 是否有任意元素满足条件 == Some
func Average ¶ added in v0.1.12
func Average[T constraintsi.Number](it iter.Seq[T]) T
Returns the average of all the elements in the iterator.
func Contains ¶ added in v0.1.12
func Contains[T comparable](it iter.Seq[T], target T) bool
Returns true if the target is included in the iterator.
func Distinct ¶ added in v0.1.0
func Distinct[T any, C comparable](seq iter.Seq[T], f types.UnaryFunction[T, C]) iter.Seq[T]
Distinct remove duplicate elements. 对序列中的元素去重
func FlatMap ¶ added in v0.1.0
FlatMap transform each element in Seq[T] to a new Seq[R]. 将原本序列中的每个元素都转换为一个新的序列, 并将所有转换后的序列依次连接起来生成一个新的序列
func Fold ¶ added in v0.1.0
func Fold[T, R any](seq iter.Seq[T], initVal R, acc types.BinaryFunction[R, T, R]) (result R)
Fold accumulate each element using the BinaryFunction starting from the initial value. 从初始值开始, 通过 acc 函数累加每个元素
func IsNotEmpty ¶ added in v0.1.12
Ruturns true if the count of Iterator is 0.
func Max ¶ added in v0.1.12
func Max[T constraints.Ordered](it iter.Seq[T]) (T, bool)
Return the maximum value of all elements of the iterator.
func Mean ¶ added in v0.3.1
func Mean[T constraintsi.Number](seq iter.Seq[T]) float64
Calculate the Mean of a slice of floats
func Min ¶ added in v0.1.12
func Min[T constraints.Ordered](it iter.Seq[T]) (T, bool)
Return the minimum value of all elements of the iterator.
func Operator ¶ added in v0.1.12
func Operator[T any](seq iter.Seq[T], add types.BinaryOperator[T]) T
func OperatorBy ¶ added in v0.1.12
func OperatorBy[T any](it iter.Seq[T], f types.BinaryOperator[T]) T
func Peek ¶ added in v0.1.0
Peek visit every element in the Seq and leave them on the Seq. 访问序列中的每个元素而不消费它
func Product ¶ added in v0.1.12
func Product[T constraintsi.Number](it iter.Seq[T]) T
Returns the product of all the elements in the iterator.
func Reduce ¶ added in v0.1.0
Reduce accumulate each element using the binary operation. 使用给定的累加函数, 累加序列中的每个元素. 序列中可能没有元素因此返回的是 Optional
func Sum ¶ added in v0.1.10
func Sum[T constraintsi.Number](it iter.Seq[T]) T
Returns the sum of all the elements in the iterator.
func SumComparable ¶ added in v0.1.10
func SumComparable[T constraints.Ordered](seq iter.Seq[T]) T
func SumCount ¶ added in v0.3.1
func SumCount[T constraintsi.Number](it iter.Seq[T]) (T, int)
Returns the sum of all the elements in the iterator.
func UntilComparable ¶ added in v0.1.10
func UntilComparable[T comparable](seq iter.Seq[T], e T) iter.Seq[T]
Types ¶
type Seq ¶ added in v0.1.0
func ChannelAll ¶ added in v0.1.0
func HashMapAll ¶ added in v0.1.0
func HashMapAll[M ~map[K]V, K comparable, V any](m M) Seq[types.Pair[K, V]]
func RangeAll ¶ added in v0.1.0
func RangeAll[T constraintsi.Number](begin, end, step T) Seq[T]
func SliceAllValues ¶ added in v0.3.1
func SliceBackward ¶ added in v0.1.0
func SliceBackwardValues ¶ added in v0.1.1
func StringRunes ¶ added in v0.1.1
func (Seq[T]) Distinct ¶ added in v0.1.0
func (it Seq[T]) Distinct(f types.UnaryFunction[T, int]) Stream[T]
func (Seq[T]) Fold ¶ added in v0.1.0
func (it Seq[T]) Fold(initVal T, acc types.BinaryOperator[T]) T
func (Seq[T]) Reduce ¶ added in v0.1.0
func (it Seq[T]) Reduce(acc types.BinaryOperator[T]) (T, bool)
func (Seq[T]) Sum ¶ added in v0.1.10
func (it Seq[T]) Sum(add types.BinaryOperator[T]) T
type Stream ¶ added in v0.1.0
type Stream[T any] interface { Seq() iter.Seq[T] Filter(types.Predicate[T]) Stream[T] Map(types.UnaryFunction[T, T]) Stream[T] //同类型转换,没啥意义 FlatMap(types.UnaryFunction[T, iter.Seq[T]]) Stream[T] //同Map Peek(types.Consumer[T]) Stream[T] Sorted(types.Comparator[T]) Stream[T] Distinct(types.UnaryFunction[T, int]) Stream[T] Limit(int) Stream[T] Until(types.Predicate[T]) Stream[T] Skip(int) Stream[T] ForEach(types.Consumer[T]) Collect() []T IsSorted(types.Comparator[T]) bool All(types.Predicate[T]) bool // every Any(types.Predicate[T]) bool // some Reduce(acc types.BinaryOperator[T]) (T, bool) Fold(initVal T, acc types.BinaryOperator[T]) T First() (T, bool) Count() int Sum(types.BinaryOperator[T]) T }