Documentation ¶
Overview ¶
Package iter implements an iterator interface as used by query.
An iterator as implemented in this package is a type that may point to an element that can be looked at via Peek. Peek may only be called if the iterator is not empty, i.e. after the last element it iterates over. This can be checked via IsEmpty. Move the iterator to its next element (or the end) via calls to Next.
Next and Peek are allowed to panic if IsEmpty returns true.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConstIter ¶
type ConstIter interface { Peek() interface{} IsEmpty() bool }
ConstIter contains all methods for an iterator that is not moved to the next element. As such, it is not very useful except as a parameter to a function that is not supposed to change the iterator.
type Iter ¶
type Iter interface { ConstIter Next() }
Iter is an iterator that can be moved to the next element. Otherwise it is the same as a ConstIter.
type SliceIter ¶
type SliceIter struct {
// contains filtered or unexported fields
}
SliceIter is a helper type that takes any slice type and returns an iterator pointing to the first element of the slice.
func NewSliceIter ¶
func NewSliceIter(slice interface{}) *SliceIter
NewSliceIter takes any slice type parameter and returns a *SliceIter that is guaranteed to implement Iter.
Calling NewSliceIter with other values is not allowed and might cause a panic.