walker

package
v0.0.0-...-15a9106 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0, BSD-2-Clause Imports: 2 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Walker

type Walker[T comparable] struct {
	// contains filtered or unexported fields
}

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

func New

func New[T comparable](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 front of the queue, which can consequently be retrieved by calling the Next method.

func (*Walker[T]) Pushed

func (w *Walker[T]) Pushed(element T) bool

Pushed returns true if the passed element was Pushed to the Walker.

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