iter

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

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