iter

package
v0.0.0-...-9c88ebf Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package iter provides logic for one dimensional iterators.

Anytime a channel iterator is used it is important to use all the values or it will leak go routines.

Index

Constants

This section is empty.

Variables

View Source
var BufferLen = 100

BufferLen is the buffer length used for channels

Functions

func FloatChan

func FloatChan(start, end, step float64) <-chan float64

FloatChan returns a chan that will iterate over the floats in the range.

Types

type FloatIterator

type FloatIterator struct {
	*IdxIterator
	FloatRange
}

FloatIterator iterates over a FloatRange

func (*FloatIterator) At

func (i *FloatIterator) At(step float64) float64

At returns the value at the given step.

func (*FloatIterator) Ch

func (i *FloatIterator) Ch() <-chan float64

Ch returns a chan that will iterate over the floats in the range.

func (*FloatIterator) Each

func (i *FloatIterator) Each(fn func(float64))

Each calls the function passed in for each value in the range.

func (*FloatIterator) Next

func (i *FloatIterator) Next() float64

Next value from the iterator

func (*FloatIterator) Reset

func (i *FloatIterator) Reset() float64

Reset to the start of the range

type FloatRange

type FloatRange struct {
	Start, End, Step float64
}

FloatRange represets a range of float64

func Include

func Include(end, step float64) FloatRange

Include creates a float range that is guarenteed to include the end value.

func (FloatRange) Ch

func (r FloatRange) Ch() <-chan float64

Ch returns a chan that will iterate over the floats in the range.

func (FloatRange) Each

func (r FloatRange) Each(fn func(float64))

Each calls the function passed in for each value in the range.

func (FloatRange) Iter

func (r FloatRange) Iter() (*FloatIterator, float64)

Iter creates a new FloatIterator from a FloatRange

type IdxIterator

type IdxIterator struct {
	IdxRange
	Idx int
}

IdxIterator coordinates iterating over an IdxRange.

func (*IdxIterator) Ch

func (i *IdxIterator) Ch() <-chan int

Ch returns a chan that will iterate from 0 to IdxRange.

func (*IdxIterator) Done

func (i *IdxIterator) Done() bool

Done will return true if the current index value is greater than or equal to IdxRange.

func (*IdxIterator) Next

func (i *IdxIterator) Next() int

Next increments and returns the Idx

func (*IdxIterator) Reset

func (i *IdxIterator) Reset() int

Reset the IdxIterator back to 0.

type IdxRange

type IdxRange int

IdxRange represents an integer range from 0 to IdxRange stepping by one.

func To

func To(end int) IdxRange

To creates an IdxRange

func (IdxRange) Ch

func (r IdxRange) Ch() <-chan int

Ch returns a chan that will iterate from 0 to IdxRange.

func (IdxRange) Iter

func (r IdxRange) Iter() (*IdxIterator, int)

Iter creates an IdxIterator from an IdxRange

type IntIterator

type IntIterator struct {
	*IdxIterator
	IntRange
}

IntIterator coordinates iterating over an IntRange.

func (*IntIterator) At

func (i *IntIterator) At(step int) int

At returns the value at the provided step.

func (*IntIterator) Ch

func (i *IntIterator) Ch() <-chan int

Ch returns a chan that will iterate over the IntRange.

func (*IntIterator) Next

func (i *IntIterator) Next() int

Next int in the range.

func (*IntIterator) Reset

func (i *IntIterator) Reset() int

Reset to the start of the range.

type IntRange

type IntRange struct {
	Start, End, Step int
}

IntRange a range of ints.

func Range

func Range(start, end int) IntRange

Range creates a range from start to end with a step of 1.

func (IntRange) Ch

func (r IntRange) Ch() <-chan int

Ch returns a chan that will iterate over the IntRange.

func (IntRange) Iter

func (r IntRange) Iter() (*IntIterator, int)

Iter creates an IntIterator from an IntRange.

Jump to

Keyboard shortcuts

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