walker

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: Apache-2.0, BSD-2-Clause Imports: 1 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Walker

type Walker[T any] struct {
	*walker.Walker
}

Walker implements a generic data structure that simplifies walks over collections or data structures.

func New

func New[T any](revisitElements ...bool) *Walker[T]

New is the constructor of the Walker. It accepts an optional boolean flag that controls whether the Walker will visit the same Element multiple times.

func (*Walker[T]) HasNext

func (w *Walker[T]) HasNext() bool

HasNext returns true if the Walker has another element that shall be visited.

func (*Walker[T]) Next

func (w *Walker[T]) Next() (nextElement T)

Next returns the next element of the walk.

func (*Walker[T]) Push

func (w *Walker[T]) Push(nextElement T) (walker *Walker[T])

Push adds a new element to the walk, which can consequently be retrieved by calling the Next method.

func (*Walker[T]) PushAll

func (w *Walker[T]) PushAll(nextElements ...T) (walker *Walker[T])

PushAll adds new elements to the walk, which can consequently be retrieved by calling the Next method.

func (*Walker[T]) PushFront

func (w *Walker[T]) PushFront(nextElements ...T) (walker *Walker[T])

PushFront adds a new element to the next steps of the walk, which can consequently be retrieved by calling the Next method.

func (*Walker[T]) Reset

func (w *Walker[T]) Reset()

Reset removes all queued elements.

func (*Walker[T]) StopWalk

func (w *Walker[T]) StopWalk()

StopWalk aborts the walk and forces HasNext to always return false.

func (*Walker[T]) WalkStopped

func (w *Walker[T]) WalkStopped() bool

WalkStopped returns true if the Walk has been stopped.

Jump to

Keyboard shortcuts

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