Documentation ¶
Overview ¶
Utilities for iterator types.
This package should be deprecated in favor of std or x/exp/iter when they are generally available without build flag constraints.
Index ¶
- Constants
- func All(iter Iter[bool]) bool
- func Any(iter Iter[bool]) bool
- func CollectMap[K comparable, V any](iter Iter[Pair[K, V]]) map[K]V
- func CollectSet[T comparable](iter Iter[T]) sets.Set[T]
- func FirstSome[T any](iter Iter[optional.Optional[T]]) optional.Optional[T]
- func Histogram[T comparable](iter Iter[T]) map[T]int
- func Sum[T constraints.Integer](iter Iter[T]) T
- type Flow
- type Iter
- func Chain[T any](iters ...Iter[T]) Iter[T]
- func Deduplicate[T comparable](iter Iter[T]) Iter[T]
- func Empty[T any]() Iter[T]
- func Enumerate[T any](iter Iter[T]) Iter[Pair[uint64, T]]
- func FlatMap[T any, U any](iter Iter[T], mapFn func(T) Iter[U]) Iter[U]
- func FromMap[K comparable, V any](m map[K]V) Iter[Pair[K, V]]
- func FromMap2[K comparable, V1 any, V2 any](m1 map[K]V1, m2 map[K]V2) Iter[Pair[K, Pair[optional.Optional[V1], optional.Optional[V2]]]]
- func FromSet[T comparable](slice sets.Set[T]) Iter[T]
- func FromSlice[T any](slice []T) Iter[T]
- func Map[T any, U any](iter Iter[T], mapFn func(T) U) Iter[U]
- func MapKeys[K comparable, V any](map_ map[K]V) Iter[K]
- func MapKvs[K comparable, V any](map_ map[K]V) Iter[Pair[K, V]]
- func MapValues[K comparable, V any](map_ map[K]V) Iter[V]
- func Range[T constraints.Integer](start, end T) Iter[T]
- func Repeat[T any](value T, count uint64) Iter[T]
- func Zip[Left, Right any](leftSlice []Left, rightSlice []Right) Iter[Pair[optional.Optional[Left], optional.Optional[Right]]]
- type Pair
- type Yield
Constants ¶
View Source
const ( Continue = Flow(true) Break = Flow(false) )
Variables ¶
This section is empty.
Functions ¶
func CollectMap ¶
func CollectMap[K comparable, V any](iter Iter[Pair[K, V]]) map[K]V
func CollectSet ¶
func CollectSet[T comparable](iter Iter[T]) sets.Set[T]
func Histogram ¶
func Histogram[T comparable](iter Iter[T]) map[T]int
func Sum ¶
func Sum[T constraints.Integer](iter Iter[T]) T
Types ¶
type Iter ¶
A pushing iterator that yields items of type `T`.
func Deduplicate ¶
func Deduplicate[T comparable](iter Iter[T]) Iter[T]
func FromMap2 ¶
func FromMap2[K comparable, V1 any, V2 any]( m1 map[K]V1, m2 map[K]V2, ) Iter[Pair[K, Pair[optional.Optional[V1], optional.Optional[V2]]]]
Iterate over the union of keys from two different maps.
func MapKeys ¶
func MapKeys[K comparable, V any](map_ map[K]V) Iter[K]
func MapValues ¶
func MapValues[K comparable, V any](map_ map[K]V) Iter[V]
func Range ¶
func Range[T constraints.Integer](start, end T) Iter[T]
func Zip ¶
func Zip[Left, Right any]( leftSlice []Left, rightSlice []Right, ) Iter[Pair[optional.Optional[Left], optional.Optional[Right]]]
Iterate over two slices concurrently, yielding `None` on up to one side if a slice is shorter.
func (Iter[T]) CollectSlice ¶
func (iter Iter[T]) CollectSlice() []T
func (Iter[T]) MustBeAffine ¶
Ensures that the iterator can only be used once. Attempt to reuse would result in panic.
func (Iter[T]) TryForEach ¶
Click to show internal directories.
Click to hide internal directories.