itertools

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Each

func Each[T any](it iterkit.Iterator[T], fn EachFunc[T])

Each walks through the iterator given in it and calls fn for every single entry.

func EachIndex

func EachIndex[T any](it iterkit.Iterator[T], fn EachIndexFunc[T])

EachIndex walks through the iterator given in it and calls fn for every single entry together with its index.

func Filter

func Filter[T any](it iterkit.Iterator[T], cb FilterFunc[T]) iterkit.Iterator[T]

Filter returns an Iterator yielding items from the given iterator for which the given FilterFunc function returns true.

func Map

func Map[T, V any](it iterkit.Iterator[T], fn MapFn[T, V]) iterkit.Iterator[V]

Map returns an iterator that applies MapFn function to every item of iterkit.Iterator iterable, yielding the results.

func Range

func Range[T constraints.Signed](stop T, optFuncs ...OptionFunc) iterkit.Iterator[T]

Range returns an iterator yielding [start, stop)

func Runes

func Runes(v string) iterkit.Iterator[rune]

Runes returns an iterator which yields all runes in the given string.

func Slice

func Slice[T any](it iterkit.Iterator[T]) (out []T)

Slice consumes the iterator iterkit.Iterator returning its elements as a Go slice.

func String

func String(it iterkit.Iterator[rune]) string

String consumes the given rune iterator and returns the content as a string.

Types

type EachFunc

type EachFunc[T any] func(item T) bool

type EachIndexFunc

type EachIndexFunc[T any] func(i int, item T) bool

type FilterFunc

type FilterFunc[T any] func(element T) bool

type FilterIter

type FilterIter[T any] struct {
	// contains filtered or unexported fields
}

func (*FilterIter[T]) Next

func (f *FilterIter[T]) Next() bool

func (FilterIter[T]) Value

func (f FilterIter[T]) Value() T

type MapFn

type MapFn[T, V any] func(T) V

type MapIterator

type MapIterator[T, V any] struct {
	// contains filtered or unexported fields
}

func (*MapIterator[T, V]) Next

func (m *MapIterator[T, V]) Next() bool

func (*MapIterator[T, V]) Value

func (m *MapIterator[T, V]) Value() V

type Option

type Option[T any] struct {
	// contains filtered or unexported fields
}

func (Option[T]) IsSome

func (o Option[T]) IsSome() bool

func (Option[T]) OrElse

func (o Option[T]) OrElse(other T) T

func (*Option[T]) Set

func (o *Option[T]) Set(val T)

type OptionFunc

type OptionFunc func(opts *RangeOptions)

func WithStart

func WithStart(v int) OptionFunc

func WithStep

func WithStep(v int) OptionFunc

type RangeIter

type RangeIter[T constraints.Signed] struct {
	// contains filtered or unexported fields
}

func (*RangeIter[T]) Next

func (r *RangeIter[T]) Next() bool

func (RangeIter[T]) Value

func (r RangeIter[T]) Value() T

type RangeOptions

type RangeOptions struct {
	// contains filtered or unexported fields
}

type StringIter

type StringIter struct {
	// contains filtered or unexported fields
}

func (*StringIter) Next

func (s *StringIter) Next() bool

func (*StringIter) Value

func (s *StringIter) Value() rune

Jump to

Keyboard shortcuts

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