walker

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0, BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Walker

type Walker struct {
	// contains filtered or unexported fields
}

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

func New

func New(revisitElements ...bool) (walker *Walker)

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) HasNext

func (w *Walker) HasNext() bool

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

func (*Walker) Next

func (w *Walker) Next() (nextElement interface{})

Next returns the next element of the walk.

func (*Walker) Push

func (w *Walker) Push(nextElement interface{}) (walker *Walker)

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

func (*Walker) Pushed

func (w *Walker) Pushed(element interface{}) bool

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

func (*Walker) Reset

func (w *Walker) Reset()

Reset removes all queued elements.

func (*Walker) StopWalk

func (w *Walker) StopWalk()

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

func (*Walker) WalkStopped

func (w *Walker) 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