iter

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: AGPL-3.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPull = errors.New("Pull error")

Functions

func CloseAny

func CloseAny(as ...any) error

func Collect

func Collect[T any](it Iter[T]) ([]T, error)

func Sample added in v0.1.8

func Sample[T any](it Iter[T], keep int, ra *rand.Rand) ([]T, error)

Types

type Decoder added in v0.1.6

type Decoder interface {
	Decode(any) error
}

type Iter

type Iter[T any] interface {
	Iterate(yield func(T) error) error
}

type Iterator

type Iterator[T any] struct {
	Iteratef func(yield func(T) error) error
	Closef   func() error
}

func Cat added in v0.1.2

func Cat[T any](its Iter[Iter[T]]) *Iterator[T]

func ChanCat added in v0.1.3

func ChanCat[T any](its Iter[Iter[T]], bufsize, threads int) *Iterator[T]

func DecoderIter added in v0.1.6

func DecoderIter[T any](d Decoder) *Iterator[T]

func IntIter

func IntIter(n int) *Iterator[int]

func MapIter

func MapIter[K comparable, V any](m map[K]V) *Iterator[KeyVal[K, V]]

func Push

func Push[T any](p Puller[T]) *Iterator[T]

func SamplePerc added in v0.1.8

func SamplePerc[T any](it Iter[T], keep float64, ra *rand.Rand) *Iterator[T]

func SliceIter

func SliceIter[T any](s []T) *Iterator[T]

func SlicePtrIter

func SlicePtrIter[T any](s []T) *Iterator[*T]

func Transform

func Transform[T, U any](it Iter[T], f func(T) (U, error)) *Iterator[U]

func Zip2 added in v0.1.9

func Zip2[T, U any](i1 Iter[T], i2 Iter[U]) *Iterator[Tuple2[T, U]]

func (*Iterator[T]) Close

func (i *Iterator[T]) Close() error

func (*Iterator[T]) Iterate

func (i *Iterator[T]) Iterate(yield func(T) error) error

type KeyVal

type KeyVal[K comparable, V any] struct {
	Key K
	Val V
}

type Path added in v0.1.5

type Path string

func (Path) Iterate added in v0.1.5

func (p Path) Iterate(yield func(string) error) (err error)

type Puller

type Puller[T any] interface {
	Next() (T, error)
}

type PushPull

type PushPull[T any] struct {
	Nextf  func() (T, error)
	Closef func() error
}

func Pull

func Pull[T any](it Iter[T], buflen int) *PushPull[T]

func (*PushPull[T]) Close

func (p *PushPull[T]) Close() error

func (*PushPull[T]) Next

func (p *PushPull[T]) Next() (T, error)

type Scanner added in v0.1.5

type Scanner struct {
	*bufio.Scanner
}

func NewScanner added in v0.1.5

func NewScanner(r io.Reader) *Scanner

func (*Scanner) Iterate added in v0.1.5

func (s *Scanner) Iterate(yield func(string) error) error

type Tuple2 added in v0.1.9

type Tuple2[T, U any] struct {
	V1 T
	V2 U
}

Jump to

Keyboard shortcuts

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