iterator

package
v1.11.11-rc.4 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Empty

type Empty[T any] struct{}

Empty is an iterator with no elements.

func (Empty[_]) Next

func (Empty[_]) Next() bool

func (Empty[_]) Release

func (Empty[_]) Release()

func (Empty[T]) Value

func (Empty[T]) Value() T

type Iterator

type Iterator[T any] interface {
	// Next attempts to move the iterator to the next element in the set. It
	// returns false once there are no more elements to return.
	Next() bool

	// Value returns the value of the current element. Value should only be called
	// after a call to Next which returned true.
	Value() T

	// Release any resources associated with the iterator. This must be called
	// after the iterator is no longer needed.
	Release()
}

Iterator defines an interface for iterating over a set.

func Filter

func Filter[T any](it Iterator[T], filter func(T) bool) Iterator[T]

Filter returns an iterator that skips the elements in [it] that return true from [filter].

func FromSlice

func FromSlice[T any](elements ...T) Iterator[T]

FromSlice returns an iterator that contains [elements] in order. Doesn't sort by anything.

func FromTree

func FromTree[T any](btree *btree.BTreeG[T]) Iterator[T]

FromTree returns a new iterator of the stakers in [tree] in ascending order. Note that it isn't safe to modify [tree] while iterating over it.

func Merge

func Merge[T any](less btree.LessFunc[T], iterators ...Iterator[T]) Iterator[T]

Merge returns an iterator that returns all of the elements of [iterators] in order.

Directories

Path Synopsis
Package iteratormock is a generated GoMock package.
Package iteratormock is a generated GoMock package.

Jump to

Keyboard shortcuts

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