Documentation
¶
Index ¶
- type Closer
- type CompareFunc
- type ComputeNext
- type DefaultIterator
- type EqualsFunc
- type Iterator
- func Concat(iterators ...Iterator) Iterator
- func Dedup(it Iterator, equalsFn EqualsFunc) Iterator
- func Filter(iter Iterator, test PredicateFunc) Iterator
- func FilterNonNil(it Iterator) Iterator
- func Limit(it Iterator, upperBound int) Iterator
- func Merge(compareFn CompareFunc, iterators ...Iterator) Iterator
- func NewCloseableIterator(computeNext ComputeNext, closer Closer) Iterator
- func NewDefaultIterator(computeNext ComputeNext) Iterator
- func Skip(it Iterator, howMany int) Iterator
- func Transform(iter Iterator, fn TransformFunc) Iterator
- type PredicateFunc
- type State
- type TransformFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompareFunc ¶
type CompareFunc func(item1 interface{}, item2 interface{}) int
type ComputeNext ¶
If there is a next element return: next, false, nil If an error occurs computing the next element return: nil, false, error If there is no next element return: nil, true, nil
type DefaultIterator ¶
type DefaultIterator struct {
ComputeNext ComputeNext
// contains filtered or unexported fields
}
func (*DefaultIterator) Close ¶
func (it *DefaultIterator) Close() error
func (*DefaultIterator) HasNext ¶
func (it *DefaultIterator) HasNext() bool
Returns true if the iterator can be continued or false if the end of data has been reached. It returns an error if the check fails.
func (*DefaultIterator) Next ¶
func (it *DefaultIterator) Next() (interface{}, error)
Returns the next item in the iteration. This method should be always called in combination with the HasNext. If the iterator reached the end of data, the method will return an error
func (*DefaultIterator) Peek ¶
func (it *DefaultIterator) Peek() (interface{}, error)
Returns the next element without continuing the iteration.
type EqualsFunc ¶
type EqualsFunc func(item1 interface{}, item2 interface{}) bool
EqualsFunc returns true is items are equal
type Iterator ¶
type Iterator interface {
HasNext() bool
Next() (interface{}, error)
Peek() (item interface{}, e error)
io.Closer
}
An iterator over a stream of data
func Filter ¶
func Filter(iter Iterator, test PredicateFunc) Iterator
Creates a wrapper-iterator over the original that will filter elements according to the filter function specified
func FilterNonNil ¶
Specific case of Filter that returns a wrapper-iterator over the original that will return only the non nil items
func Limit ¶
Creates an wrapper-iterator over the original that will iterate until there are no more items or the 'upperBound' is reached.
func Merge ¶
func Merge(compareFn CompareFunc, iterators ...Iterator) Iterator
Merge combines multiple sorted iterators into a single sorted iterator.
func NewCloseableIterator ¶
func NewCloseableIterator(computeNext ComputeNext, closer Closer) Iterator
Given a way to compute next and a close handler, return a closeable iterator
func NewDefaultIterator ¶
func NewDefaultIterator(computeNext ComputeNext) Iterator
Given a way to compute next, returns an iterator
func Skip ¶
Creates an wrapper-iterator over the original that will skip the first 'numberOfElementsToSkip' items
func Transform ¶
func Transform(iter Iterator, fn TransformFunc) Iterator
Creates an wrapper-iterator over the original that will transform elements according to the filter function specified
type PredicateFunc ¶
type TransformFunc ¶
type TransformFunc func(item interface{}) (interface{}, error)