Documentation
¶
Index ¶
- func Collect[T any](itr Iterator[T]) ([]T, error)
- func CollectInto[T any](itr Iterator[T], into []T) ([]T, error)
- func Identity[A any](a A) A
- type CancellableIter
- type CloseIter
- type CloseIterator
- type CloseResetIterator
- type CloserIter
- type CountIterator
- type CounterIter
- type DedupeIter
- type EmptyIter
- type FilterIter
- type Iterator
- type MapIter
- type Ord
- type Orderable
- type OrderedImpl
- type PeekCloseIter
- type PeekCloseIterator
- type PeekIter
- type PeekIterator
- type Predicate
- type ResetIterator
- type SeekIterator
- type SizedIterator
- type SliceIter
- type UnlessIterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Collect ¶
func Collect[T any](itr Iterator[T]) ([]T, error)
Collect collects an interator into a slice. It uses CollectInto with a new slice
func CollectInto ¶
func CollectInto[T any](itr Iterator[T], into []T) ([]T, error)
CollectInto collects the elements of an iterator into a provided slice which is returned
Types ¶
type CancellableIter ¶
type CancellableIter[T any] struct {
Iterator[T]
// contains filtered or unexported fields
}
func NewCancelableIter ¶
func NewCancelableIter[T any](ctx context.Context, itr Iterator[T]) *CancellableIter[T]
type CloseIter ¶
type CloseIter[T any] struct {
Iterator[T]
// contains filtered or unexported fields
}
type CloseIterator ¶
type CloseIterator[T any] interface {
Iterator[T]
Close() error
}
type CloseResetIterator ¶
type CloseResetIterator[T any] interface {
CloseIterator[T]
ResetIterator[T]
}
type CloserIter ¶
type CloserIter[T io.Closer] struct {
Iterator[T]
}
func NewCloserIter ¶
func NewCloserIter[T io.Closer](itr Iterator[T]) *CloserIter[T]
type CountIterator ¶
type CountIterator[T any] interface {
Iterator[T]
Count() int
}
type CounterIter ¶
type CounterIter[T any] struct {
Iterator[T] // the underlying iterator
// contains filtered or unexported fields
}
func NewCounterIter ¶
func NewCounterIter[T any](itr Iterator[T]) *CounterIter[T]
type DedupeIter ¶
type DedupeIter[A, B any] struct {
// contains filtered or unexported fields
}
DedupeIter is a deduplicating iterator which creates an Iterator[B] from a sequence of Iterator[A].
func NewDedupingIter ¶
func NewDedupingIter[A, B any](
eq func(A, B) bool,
from func(A) B,
merge func(A, B) B,
itr PeekIterator[A],
) *DedupeIter[A, B]
type EmptyIter ¶
type EmptyIter[T any] struct {
// contains filtered or unexported fields
}
func NewEmptyIter ¶
func NewEmptyIter[T any]() *EmptyIter[T]
type FilterIter ¶
type FilterIter[T any] struct {
Iterator[T]
// contains filtered or unexported fields
}
func NewFilterIter ¶
func NewFilterIter[T any](it Iterator[T], p Predicate[T]) *FilterIter[T]
type Iterator ¶
type Iterator[T any] interface {
Next() bool
Err() error
At() T
}
Iterator is the basic iterator type with the common functions for advancing and retrieving the current value.
General usage of the iterator:
for it.Next() {
curr := it.At()
// do something
}
if it.Err() != nil {
// do something
}
type MapIter ¶
type MapIter[A any, B any] struct {
Iterator[A]
// contains filtered or unexported fields
}
func NewMapIter ¶
func NewMapIter[A any, B any](src Iterator[A], f func(A) B) *MapIter[A, B]
type Orderable ¶
type Orderable[T any] interface {
// Return the caller's position relative to the target
Compare(T) Ord
}
type OrderedImpl ¶
type OrderedImpl[T any] struct {
// contains filtered or unexported fields
}
func NewOrderable ¶
func NewOrderable[T any](val T, cmp func(T, T) Ord) OrderedImpl[T]
convenience method for creating an Orderable implementation for a type dynamically by passing in a value and a comparison function This is useful for types that are not under our control, such as built-in types and for reducing boilerplate in testware/etc. Hot-path code should use a statically defined Orderable implementation for performance
type PeekCloseIter ¶
type PeekCloseIter[T any] struct {
*PeekIter[T]
// contains filtered or unexported fields
}
func NewPeekCloseIter ¶
func NewPeekCloseIter[T any](itr CloseIterator[T]) *PeekCloseIter[T]
type PeekCloseIterator ¶
type PeekCloseIterator[T any] interface {
PeekIterator[T]
CloseIterator[T]
}
type PeekIter ¶
type PeekIter[T any] struct {
// contains filtered or unexported fields
}
func NewPeekIter ¶
func NewPeekIter[T any](itr Iterator[T]) *PeekIter[T]
type PeekIterator ¶
type PeekIterator[T any] interface {
Iterator[T]
Peek() (T, bool)
}
type ResetIterator ¶
type ResetIterator[T any] interface {
Reset() error
Iterator[T]
}
type SeekIterator ¶
type SeekIterator[K, V any] interface {
Iterator[V]
Seek(K) error
}
type SizedIterator ¶
type SizedIterator[T any] interface {
Iterator[T]
Remaining() int // remaining
}
type SliceIter ¶
type SliceIter[T any] struct {
// contains filtered or unexported fields
}
func NewSliceIter ¶
func NewSliceIter[T any](xs []T) *SliceIter[T]
type UnlessIterator ¶
type UnlessIterator[T Orderable[T]] struct {
// contains filtered or unexported fields
}
func NewUnlessIterator ¶
func NewUnlessIterator[T Orderable[T]](a, b Iterator[T]) *UnlessIterator[T]
Iterators _must_ be sorted. Defers to underlying `PeekingIterator` implementation for both iterators if they implement it.