iter

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CircularSlice

func CircularSlice[T any](slice []T) iter.Seq[T]

func CircularSlice2

func CircularSlice2[T any](slice []T) iter.Seq2[int, T]

func Fold

func Fold[A any, B any](ite Iterator[A], acc B,
	fn func(A, B) B) B

func ParallelFilter

func ParallelFilter[T any](ite iter.Seq[T], filterFunc FilterFunc[T],
	maxCpuCount ...int) iter.Seq[T]

Does not preserve order

func ParallelMap

func ParallelMap[A any, B any](ite Iterator[A], fn func(A) B,
	maxCpuCount ...int) iter.Seq[B]

Does not preserve order

func RangeN

func RangeN(n int) iter.Seq[int]

func Zip

func Zip[A any, B any](ite1 iter.Seq[A], ite2 iter.Seq[B]) iter.Seq2[A, B]

Types

type FilterFunc

type FilterFunc[T any] func(T) bool

type Iterator added in v0.2.0

type Iterator[T any] iter.Seq[T]

func FromSlice

func FromSlice[T any](slice []T) Iterator[T]

func Map

func Map[A any, B any](ite Iterator[A], fn func(A) B) Iterator[B]

func (Iterator[T]) AdvanceBy added in v0.2.0

func (ite Iterator[T]) AdvanceBy(n int) []T

Moves the iterator forward by up to n elements. Returns the elements which have been passed.

func (Iterator[T]) All added in v0.2.0

func (ite Iterator[T]) All(fn FilterFunc[T]) bool

Returns if all the values in the iterator have returned true from the fn provided. Consumes the iterator.

func (Iterator[T]) Collect added in v0.2.0

func (ite Iterator[T]) Collect() []T

func (Iterator[T]) Count added in v0.2.0

func (ite Iterator[T]) Count() int

Returns the number of elements in the iterator, consuming it.

func (Iterator[T]) Enumerate added in v0.2.0

func (ite Iterator[T]) Enumerate() Iterator2[int, T]

func (Iterator[T]) Filter added in v0.2.0

func (ite Iterator[T]) Filter(fn FilterFunc[T]) Iterator[T]

Returns the elements which return true from the fn provided.

func (Iterator[T]) FirstN added in v0.2.0

func (ite Iterator[T]) FirstN(n int) Iterator[T]

func (Iterator[T]) ForEach added in v0.2.0

func (ite Iterator[T]) ForEach(fn func(T))

func (Iterator[T]) Intersperse added in v0.2.0

func (ite Iterator[T]) Intersperse(seperator T) Iterator[T]

func (Iterator[T]) Last added in v0.2.0

func (ite Iterator[T]) Last() (*T, bool)

func (Iterator[T]) Nth added in v0.2.0

func (ite Iterator[T]) Nth(n int) (*T, bool)

Returns the nth element in the iterator, and true if the value exists. Else, returns nil and false.

func (Iterator[T]) Partition added in v0.2.0

func (ite Iterator[T]) Partition(fn FilterFunc[T]) (
	trueV []T, falseV []T)

Paritions the iterator into two slices, one for the true values and one for the false values. Consumes the iterator.

func (Iterator[T]) Reduce added in v0.2.0

func (ite Iterator[T]) Reduce(fn func(T, T) T) T

type Iterator2 added in v0.2.0

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

func FromMap

func FromMap[K comparable, V any](m map[K]V) Iterator2[K, V]

Jump to

Keyboard shortcuts

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