stream

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllMatch

func AllMatch[T any](it iter.Seq[T], test Predicate[T]) bool

AllMatch test if every elements are all match the Predicate. 是否每个元素都满足条件

func AnyMatch

func AnyMatch[T any](it iter.Seq[T], test Predicate[T]) bool

AnyMatch test if any element matches the Predicate. 是否有任意元素满足条件

func Collect

func Collect[T any](it iter.Seq[T]) (result []T)

Collect return all elements as a slice. 将序列中所有元素收集为切片返回

func Count

func Count[T any](it iter.Seq[T]) (count int64)

Count return the count of elements in the Seq. 返回序列中的元素个数

func Distinct

func Distinct[T any, Cmp comparable](it iter.Seq[T], f Function[T, Cmp]) iter.Seq[T]

Distinct remove duplicate elements. 对序列中的元素去重

func Filter

func Filter[T any](it iter.Seq[T], test Predicate[T]) iter.Seq[T]

Filter keep elements which satisfy the Predicate. 保留满足断言的元素

func FindFirst

func FindFirst[T any](it iter.Seq[T]) *types.Option[T]

FindFirst find the first element in the Seq. 返回序列中的第一个元素(如有).

func FlatMap

func FlatMap[T, R any](it iter.Seq[T], flatten Function[T, iter.Seq[R]]) iter.Seq[R]

FlatMap transform each element in Seq[T] to a new Seq[R]. 将原本序列中的每个元素都转换为一个新的序列, 并将所有转换后的序列依次连接起来生成一个新的序列

func ForEach

func ForEach[T any](it iter.Seq[T], accept Consumer[T])

ForEach consume every elements in the Seq. 消费序列中的每个元素

func Limit

func Limit[T any, Number constraints.Number](it iter.Seq[T], limit Number) iter.Seq[T]

Limit limits the number of elements in Seq. 限制元素个数

func Map

func Map[T, R any](it iter.Seq[T], f Function[T, R]) iter.Seq[R]

Map transform the element use Fuction. 使用输入函数对每个元素进行转换

func NoneMatch

func NoneMatch[T any](it iter.Seq[T], test Predicate[T]) bool

NoneMatch test if none element matches the Predicate. 是否没有元素满足条件

func Peek

func Peek[T any](it iter.Seq[T], accept Consumer[T]) iter.Seq[T]

Peek visit every element in the Seq and leave them on the Seq. 访问序列中的每个元素而不消费它

func Reduce

func Reduce[T any](it iter.Seq[T], acc BinaryOperator[T]) *types.Option[T]

Reduce accumulate each element using the binary operation. 使用给定的累加函数, 累加序列中的每个元素. 序列中可能没有元素因此返回的是 Optional

func ReduceFrom

func ReduceFrom[T any](it iter.Seq[T], initVal T, acc BinaryOperator[T]) (result T)

ReduceFrom accumulate each element using the binary operation starting from the initial value. 从初始值开始, 通过 acc 二元运算累加每个元素

func ReduceWith

func ReduceWith[T, R any](it iter.Seq[T], initVal R, acc BiFunction[R, T, R]) (result R)

ReduceWith accumulate each element using the BiFunction starting from the initial value. 从初始值开始, 通过 acc 函数累加每个元素

func Skip

func Skip[T any, Number constraints.Number](it iter.Seq[T], skip Number) iter.Seq[T]

Skip drop some elements of the Seq. 跳过指定个数的元素

func Sorted

func Sorted[T any](it iter.Seq[T], cmp Comparator[T]) iter.Seq[T]

Sorted sort elements in the Seq by Comparator. 对序列中的元素排序

Types

This section is empty.

Jump to

Keyboard shortcuts

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