Documentation
¶
Index ¶
- func Collect[E any](it Iterator[E]) []E
- func Group[K comparable, E, R any](it Iterator[E], extract func(E) (K, R)) map[K][]R
- func Iter[E any](it Iterator[E]) iter.Seq[E]
- func Iter2[K, V any](it Iterator[lapluma.Pair[K, V]]) iter.Seq2[K, V]
- func Reduce[E, R any](it Iterator[E], handler func(R, E) R, initial R) R
- type BaseIterator
- type FilterIterator
- type Iterator
- func Filter[E any](it Iterator[E], filter func(E) bool) Iterator[E]
- func FromMap[K comparable, V any](data map[K]V) Iterator[lapluma.Pair[K, V]]
- func FromSlice[E any](data []E) Iterator[E]
- func Map[E, R any](it Iterator[E], handler func(E) R) Iterator[R]
- func TryMap[E, R any](it Iterator[E], handler func(E) (R, error)) Iterator[R]
- type MapIterator
- type TryMapIterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Group ¶
func Group[K comparable, E, R any](it Iterator[E], extract func(E) (K, R)) map[K][]R
`Group` and `Map` not support error handler if source data have some invalid value, should use `Filter` to filter data before call `Group“ or `Map` or `Reduce` if some external resources faile, `extract` or `handler` should panic or return some default value
Types ¶
type BaseIterator ¶
type BaseIterator[E any] struct { // contains filtered or unexported fields }
func (*BaseIterator[E]) Next ¶
func (it *BaseIterator[E]) Next() (E, bool)
type FilterIterator ¶
type FilterIterator[E any] struct { // contains filtered or unexported fields }
func (*FilterIterator[E]) Next ¶
func (it *FilterIterator[E]) Next() (E, bool)
type Iterator ¶
type Iterator[E any] interface { // !!! 在任何转换迭代器的 Next() 方法内部,严禁使用 for-range 模式从上游迭代器获取数据。 // 必须使用传统的、最高效的方式 // 禁用 for-range 约束仅限于`Next()`,若使用 for-rang // 每次调用Next都将创建一个iter.Seq对象,Collect等函数需要遍历,则影响不大 Next() (E, bool) }
func FromSlice ¶
support function to help create iterator from slice and map Iterator 用于串行处理场景,不支持并发,如果需要在并发场景下使用 调用pipe.`FromIterator`将其转换为Pipe
type MapIterator ¶
type MapIterator[E, R any] struct { // contains filtered or unexported fields }
func (*MapIterator[E, R]) Next ¶
func (it *MapIterator[E, R]) Next() (R, bool)
type TryMapIterator ¶
type TryMapIterator[E, R any] struct { // contains filtered or unexported fields }
TryMapIterator 用于处理那些可能会发生错误的操作
func (*TryMapIterator[E, R]) Next ¶
func (it *TryMapIterator[E, R]) Next() (R, bool)
Click to show internal directories.
Click to hide internal directories.