iter

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 0 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package iter implement a generic Iterator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

type Iterator[T any] interface {
	// Next checks whether if the iteration has more elements and
	// returns the next one if exists.
	Next() (T, bool)
}

An Iterator is a stream of items of some type.

func Empty

func Empty[T any]() Iterator[T]

Empty returns an iterator that never returns anything.

func Flatten

func Flatten[T any](from Iterator[Iterator[T]]) Iterator[T]

Flatten applies a function to all items of the specified iterator, returning an iterator for each item. The resulting iterators are then concatenated into a single iterator.

func FromSlice

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

FromSlice creates a new iterator which returns all items from the slice starting at index 0 until all items are consumed.

func Map

func Map[T any, O any](from Iterator[T], mapFunc func(T) O) Iterator[O]

Map returns a new iterator which applies a function to all items from the input iterator which are subsequently returned.

The mapping function should not mutate the state outside its scope.

Directories

Path Synopsis
Package sort provides a generic iterator that merges multiple sorted iterators.
Package sort provides a generic iterator that merges multiple sorted iterators.

Jump to

Keyboard shortcuts

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