Documentation ¶
Index ¶
- type Walker
- func (w *Walker[T]) HasNext() bool
- func (w *Walker[T]) Next() (nextElement T)
- func (w *Walker[T]) Push(nextElement T) (walker *Walker[T])
- func (w *Walker[T]) PushAll(nextElements ...T) (walker *Walker[T])
- func (w *Walker[T]) PushFront(nextElements ...T) (walker *Walker[T])
- func (w *Walker[T]) Reset()
- func (w *Walker[T]) StopWalk()
- func (w *Walker[T]) WalkStopped() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Walker ¶
Walker implements a generic data structure that simplifies walks over collections or data structures.
func New ¶
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 ¶
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 ¶
Push adds a new element to the walk, which can consequently be retrieved by calling the Next method.
func (*Walker[T]) PushAll ¶
PushAll adds new elements to the walk, which can consequently be retrieved by calling the Next method.
func (*Walker[T]) PushFront ¶
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]) StopWalk ¶
func (w *Walker[T]) StopWalk()
StopWalk aborts the walk and forces HasNext to always return false.
func (*Walker[T]) WalkStopped ¶
WalkStopped returns true if the Walk has been stopped.