generator

package
v0.0.0-...-f2fae0e Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CountIterator

type CountIterator[T constraints.Integer] struct {
	// contains filtered or unexported fields
}

func Count

func Count[T constraints.Integer](start T) *CountIterator[T]

Count returns an iterator that counts up from the given start value.

func CountBy

func CountBy[T constraints.Integer](start, step T) *CountIterator[T]

CountBy returns an iterator that counts up from the given start value with the given step.

func (*CountIterator[T]) Chan

func (ci *CountIterator[T]) Chan() <-chan T

Chan returns a channel that yields the elements of the underlying iterator.

func (*CountIterator[T]) Next

func (ci *CountIterator[T]) Next() bool

Next advances the iterator to the next element.

func (*CountIterator[T]) Value

func (ci *CountIterator[T]) Value() T

Value returns the current element.

type CycleIterator

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

func Cycle

func Cycle[T any](elements []T) *CycleIterator[T]

Cycle returns an iterator that endlessly cycles through the elements of the input slice.

func CycleLiteral

func CycleLiteral[T any](elements ...T) *CycleIterator[T]

CycleLiteral returns an iterator that endlessly cycles through the given elements.

func (*CycleIterator[T]) Chan

func (ci *CycleIterator[T]) Chan() <-chan T

Chan returns a channel that yields the elements of the underlying iterator.

func (*CycleIterator[T]) Next

func (ci *CycleIterator[T]) Next() bool

Next advances the iterator to the next element.

func (*CycleIterator[T]) Value

func (ci *CycleIterator[T]) Value() T

Value returns the current element.

type FromFnIterator

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

func FromFn

func FromFn[T any](fn func() (T, bool)) *FromFnIterator[T]

FromFn returns an iterator that generates elements by calling the given function.

func (*FromFnIterator[T]) Chan

func (ffi *FromFnIterator[T]) Chan() <-chan T

Chan returns a channel that yields the elements of the underlying iterator.

func (*FromFnIterator[T]) Collect

func (ffi *FromFnIterator[T]) Collect() []T

Collect returns all remaining elements in the iterator.

func (*FromFnIterator[T]) Next

func (ffi *FromFnIterator[T]) Next() bool

Next advances the iterator to the next element.

func (*FromFnIterator[T]) Value

func (ffi *FromFnIterator[T]) Value() T

Value returns the current element.

type RangeIterator

type RangeIterator[T constraints.Integer] struct {
	// contains filtered or unexported fields
}

RangeIterator is an iterator that produces a sequence of integers.

func Range

func Range[T constraints.Integer](start, end T) *RangeIterator[T]

Range returns a RangeIterator for the given start and end values and a step of 1.

func RangeBy

func RangeBy[T constraints.Integer](start, end, step T) *RangeIterator[T]

RangeBy returns a RangeIterator for the given start, end and step values.

func (*RangeIterator[T]) Chan

func (ri *RangeIterator[T]) Chan() <-chan T

Chan returns a channel that yields the elements of the underlying iterator.

func (*RangeIterator[T]) Collect

func (ri *RangeIterator[T]) Collect() []T

Collect returns all the values of the range as a slice.

func (*RangeIterator[T]) Next

func (ri *RangeIterator[T]) Next() bool

Next advances the iterator to the next value of the underlying slice. It returns false if the range was exhausted.

func (*RangeIterator[T]) Value

func (ri *RangeIterator[T]) Value() T

Value returns the current value of the range pointed by the iterator. If the range was exhausted, returned value is unspecified.

type RepeatIterator

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

func Repeat

func Repeat[T any](value T) *RepeatIterator[T]

Repeat returns a RepeatIterator for the given value.

func (*RepeatIterator[T]) Chan

func (ri *RepeatIterator[T]) Chan() <-chan T

Chan returns a channel that yields the elements of the underlying iterator.

func (*RepeatIterator[T]) Next

func (ri *RepeatIterator[T]) Next() bool

Next advances the iterator to the next value of the underlying slice. It returns false if the slice was exhausted.

func (*RepeatIterator[T]) Value

func (ri *RepeatIterator[T]) Value() T

Value returns the same value over and over again.

Jump to

Keyboard shortcuts

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