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 ¶
var BufferLen = 100
BufferLen is the buffer length used for channels
Functions ¶
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) 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 ¶
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.
type IdxRange ¶
type IdxRange int
IdxRange represents an integer range from 0 to IdxRange stepping by one.
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.
type IntRange ¶
type IntRange struct {
Start, End, Step int
}
IntRange a range of ints.
func (IntRange) Iter ¶
func (r IntRange) Iter() (*IntIterator, int)
Iter creates an IntIterator from an IntRange.