iterators

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoNextElement error = fmt.Errorf("Next() called on empty iterator")
)

Functions

This section is empty.

Types

type Iterable

type Iterable[T any] interface {
	// Iterator returns an Iterator over the contained elements.
	// Note that the behavior is undefined if the underlying collection is modified while being iterated over.
	Iterator() Iterator[T]
}

type Iterator

type Iterator[T any] interface {

	// Next returns the next element of the iterated collection.
	// Panics if there is no next element.
	Next() T

	// HasNext returns true if there is a next element.
	HasNext() bool
}

type LinkedIterator

type LinkedIterator[T any] struct {
	// contains filtered or unexported fields
}

func NewLinkedIterator

func NewLinkedIterator[T any](start LinkedIteratorElement[T], isValidFunc func(LinkedIteratorElement[T]) bool) *LinkedIterator[T]

NewLinkedIterator returns a new LinkedIterator.

func (*LinkedIterator[T]) HasNext

func (i *LinkedIterator[T]) HasNext() bool

func (*LinkedIterator[T]) Next

func (i *LinkedIterator[T]) Next() T

type LinkedIteratorElement

type LinkedIteratorElement[T any] interface {
	// Next returns the next element.
	Next() LinkedIteratorElement[T]
	// Value returns the value of the element.
	Value() T
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL