iterator

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 0 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Channel

func Channel[T any](iterator Iterator, constructor func() T) chan T

Channel converts an Iterator into a channel of items. You must include a constructor function that generates fully initialized values of the type you want to return.

func ChannelWithCancel

func ChannelWithCancel[T any](iterator Iterator, constructor func() T, cancel <-chan bool) chan T

Channel converts an Iterator into a channel of items. You must include a constructor function that generates fully initialized values of the type you want to return.

func Map

func Map[In any, Out any](it Iterator, fn func(In) Out) []Out

Map converts an iterator into a slice of items.

func Slice

func Slice[T any](iterator Iterator, constructor func() T) []T

Slice converts an Iterator into a slice of items. You must include a constructor function that generates fully initialized values of the type you want to return.

Types

type Iterator

type Iterator interface {
	Next(any) bool
	Count() int
}

Iterator interface allows callers to iterator over a large number of items in an array/slice

Jump to

Keyboard shortcuts

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