iter

package
v1.6.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distinct2

func Distinct2[K, V any, Cmp comparable](seq iter.Seq2[K, V], f Function2[K, V, Cmp]) iter.Seq2[K, V]

func Filter2

func Filter2[K, V any](seq iter.Seq2[K, V], test Predicate2[K, V]) iter.Seq2[K, V]

func MapKeys

func MapKeys[K, V, R any](seq iter.Seq2[K, V], f Function2[K, V, R]) iter.Seq2[R, V]

func MapValues

func MapValues[K, V, R any](seq iter.Seq2[K, V], f Function2[K, V, R]) iter.Seq2[K, R]

func Peek2

func Peek2[K, V any](seq iter.Seq2[K, V], accept Consumer2[K, V]) iter.Seq2[K, V]

Types

type Comparator2

type Comparator2[K, V any] func(K, V, K, V) bool

Comparator 比较两个元素. 第一个元素大于第二个元素时,返回正数; 第一个元素小于第二个元素时,返回负数; 否则返回 0.

type Consumer2

type Consumer2[K, V any] func(K, V)

Consumer 消费一个元素

type Function2

type Function2[K, V, R any] func(K, V) R

Function 将一个类型转为另一个类型

type Predicate2

type Predicate2[K, V any] func(K, V) bool

Predicate 断言是否满足指定条件

type Seq2

type Seq2[K, V any] iter.Seq2[K, V]

func HashMapSeq2Of added in v1.6.5

func HashMapSeq2Of[K comparable, V any](m map[K]V) Seq2[K, V]

func SliceSeq2Of added in v1.6.5

func SliceSeq2Of[T any](input []T) Seq2[int, T]

type Stream2

type Stream2[K, V any] interface {
	Seq2() iter.Seq2[K, V]

	Filter(Predicate2[K, V]) Stream2[K, V]
	Peek(Consumer2[K, V]) Stream2[K, V]

	Distinct(Function2[K, V, int]) Stream2[K, V]
	SortedByKeys(Comparator[K]) Stream2[K, V]
	SortedByValues(Comparator[V]) Stream2[K, V]
	Limit(int64) Stream2[K, V]
	Skip(int64) Stream2[K, V]

	ForEach(Consumer2[K, V])
	CollectKeys() []K
	CollectValues() []V
	AllMatch(Predicate2[K, V]) bool
	NoneMatch(Predicate2[K, V]) bool
	AnyMatch(Predicate2[K, V]) bool

	First() (K, V)
	Count() int64
}

type Supplier2

type Supplier2[K, V any] func() (K, V)

Supplier 产生一个元素

Jump to

Keyboard shortcuts

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