Documentation ¶
Overview ¶
Package iter provides various types of iterators including generic array iterator, directory iterator and integer range iterator. These iterators are designed to provide a simple and consistent interface for iterating over collections or ranges.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirIterator ¶
type DirIterator struct {
// contains filtered or unexported fields
}
DirIterator represents a directory iterator.
func NewDirIterator ¶
func NewDirIterator(root string) (*DirIterator, error)
NewDirIterator creates a new directory iterator with the specified root directory.
func (*DirIterator) Next ¶
func (iter *DirIterator) Next() (string, error)
Next returns the next subdirectory.
type IntRangeIterator ¶
type IntRangeIterator struct {
Start, End, Current int
}
IntRangeIterator is a type for iterating over a range of integers.
func NewIntRangeIterator ¶
func NewIntRangeIterator(start, end int) *IntRangeIterator
NewIntRangeIterator creates a new IntRangeIterator instance.
func (*IntRangeIterator) Next ¶
func (it *IntRangeIterator) Next() (int, bool)
Next returns the next integer in the range and a boolean indicating if there are more values.
func (*IntRangeIterator) Reset ¶
func (it *IntRangeIterator) Reset()
Reset resets the IntRangeIterator to its initial state.
type LoopIteratorr ¶
type LoopIteratorr[T any] struct { // contains filtered or unexported fields }
LoopIteratorr represents an endless/loop iterator for a generic array.
func NewLoopIterator ¶
func NewLoopIterator[T any](data []T) *LoopIteratorr[T]
NewIterator creates a new iterator for the given array.
func (*LoopIteratorr[T]) Next ¶
func (iter *LoopIteratorr[T]) Next() T
Next returns the next value from the iterator.
func (*LoopIteratorr[T]) Reset ¶
func (iter *LoopIteratorr[T]) Reset()
type LoopingIntRangeIterator ¶
type LoopingIntRangeIterator struct {
Start, End, Current int
}
LoopingIntRangeIterator is a type for iterating over a range of integers in a loop.
func NewLoopingIntRangeIterator ¶
func NewLoopingIntRangeIterator(start, end int) *LoopingIntRangeIterator
NewLoopingIntRangeIterator creates a new LoopingIntRangeIterator instance.
func (*LoopingIntRangeIterator) Next ¶
func (it *LoopingIntRangeIterator) Next() int
Next returns the next integer in the range and loops back to the start if it reaches the end.
func (*LoopingIntRangeIterator) Reset ¶
func (it *LoopingIntRangeIterator) Reset()
Reset resets the LoopingIntRangeIterator.