Documentation
¶
Overview ¶
iterator provides the Collection and Iterator interfaces, as well as supporting functions (e.g. zip, map, filter, enumerate, etc.).
Index ¶
- func All[T any](iter Iterator[T], pred FilterFunc[T]) (bool, error)
- func Any[T any](iter Iterator[T], pred FilterFunc[T]) (bool, error)
- func Fold[T any, U any](iter Iterator[T], init *U, fn func(*U, T)) (*U, error)
- func ForEach[T any](iter Iterator[T], fn func(*T)) error
- func None[T any](iter Iterator[T], pred FilterFunc[T]) (bool, error)
- func Reduce[T, U any](iter Iterator[T], fn func(*U, T)) (*U, error)
- type Adaptor
- type AdaptorFunc
- type Enumerate
- type EnumerateError
- type EnumerateItem
- type Fill
- type Filter
- type FilterFunc
- type FromIterator
- type Generate
- type IntoIterator
- type Iterable
- type Iterator
- type Map
- type MapFunc
- type Reverse
- type Zip
- type ZipError
- type ZipItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
func All[T any](iter Iterator[T], pred FilterFunc[T]) (bool, error)
All returns true if for all items in the iterator, pred returns true. Returns false, error upon collection error.
func Any ¶
func Any[T any](iter Iterator[T], pred FilterFunc[T]) (bool, error)
Any returns true if for any item in the iterator, pred returns true. Returns false, error upon collection error.
func None ¶
func None[T any](iter Iterator[T], pred FilterFunc[T]) (bool, error)
None returns true if for all items in the iterator, pred returns false. Returns false, error upon collection error.
Types ¶
type Adaptor ¶
type Adaptor[T, Ctx any] struct { // contains filtered or unexported fields }
func NewAdaptor ¶
func NewAdaptor[T, Ctx any](ctx Ctx, pred AdaptorFunc[T, Ctx]) *Adaptor[T, Ctx]
type AdaptorFunc ¶
type Enumerate ¶
type Enumerate[T any] struct { // contains filtered or unexported fields }
Enumerate is an iterator that provides the index of the current item being iterated over.
func NewEnumerate ¶
NewEnumerate constructs a new Enumerate over an iterator.
func (*Enumerate[T]) Next ¶
func (e *Enumerate[T]) Next() (*EnumerateItem[T], error)
Next returns the next item in the Enumerate. Returns item, EnumerateError on collection error. This method implements the Iterator interface.
type EnumerateError ¶
type EnumerateError struct {
// contains filtered or unexported fields
}
EnumerateError is the error type associated with an Enumerate.
func (EnumerateError) Error ¶
func (e EnumerateError) Error() string
Error returns the error message of an EnumerateError.
type EnumerateItem ¶
EnumerateItem is the item over which an Enumerate iterates.
type Filter ¶
type Filter[T any] struct { // contains filtered or unexported fields }
Filter transforms an iterator by filtering out items based on a predicate function.
type FilterFunc ¶
FilterPredicate is a function that returns true if the item should be included in the resulting iterator.
type FromIterator ¶
type FromIterator[T any] interface { gollections.Collect[T] FromIterator(Iterator[T]) error }
type IntoIterator ¶
type Iterable ¶
type Iterable[T any] interface { IntoIterator[T] FromIterator[T] }
type Map ¶
type Map[T, U any] struct { // contains filtered or unexported fields }
Map transforms an iterator over one type into an iterator over another type, converting each item via pred. Returns Iterator[U], error on collection error.
type Zip ¶
type Zip[T, U any] struct { // contains filtered or unexported fields }
Zip combines two iterators of potentially different item types.