traversal

package
v1.2.120 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

https://en.wikipedia.org/wiki/Breadth-first_search

https://en.wikipedia.org/wiki/Depth-first_search

https://en.wikipedia.org/wiki/Tree_traversal#In-order_(LNR)

https://en.wikipedia.org/wiki/Tree_traversal#Out-order_(RNL)

https://en.wikipedia.org/wiki/Tree_traversal#Post-order_(LRN)

https://en.wikipedia.org/wiki/Tree_traversal#Post-order_(LRN)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BreadthFirstSearchOrder

func BreadthFirstSearchOrder(node any, handler Handler)

TODO template in Go2.0 is expected BreadthFirstSearchOrder traversals from node ele by Breadth-first search (BFS) ele is a node which may have some interfaces implemented: LeftNodes|MiddleNodes|RightNodes

func DepthFirstSearchOrder

func DepthFirstSearchOrder(node any, handler Handler)

TODO template in Go2.0 is expected DepthFirstSearchOrder traversals from node ele by Depth-first search (DFS) ele is a node which may have some interfaces implemented: LeftNodes|MiddleNodes|RightNodes

func Inorder

func Inorder(node any, handler Handler)

TODO template in Go2.0 is expected Inorder traversals from node ele by In-order (LNR) ele is a node which may have some interfaces implemented: LeftNodes|MiddleNodes|RightNodes

func Outorder

func Outorder(node any, handler Handler)

TODO template in Go2.0 is expected Outorder traversals from node ele by Out-order (RNL) ele is a node which may have some interfaces implemented: LeftNodes|MiddleNodes|RightNodes

func Postorder

func Postorder(node any, handler Handler)

TODO template in Go2.0 is expected Postorder traversals from node ele by Post-order (LRN) ele is a node which may have some interfaces implemented: LeftNodes|MiddleNodes|RightNodes

func Preorder

func Preorder(node any, handler Handler)

TODO template in Go2.0 is expected Preorder traversals from node ele by Pre-order (NLR) ele is a node which may have some interfaces implemented: LeftNodes|MiddleNodes|RightNodes

Types

type Handler

type Handler interface {
	Handle(node any, depth int) (goon bool)
}

type HandlerFunc

type HandlerFunc func(node any, depth int) (goon bool)

The HandlerFunc type is an adapter to allow the use of ordinary functions as traversal handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f.

func (HandlerFunc) Handle

func (f HandlerFunc) Handle(node any, depth int) (goon bool)

ServeHTTP calls f(w, r).

type LeftNodes

type LeftNodes interface {
	// Left returns the left node list or nil.
	LeftNodes() []any
}

type MiddleNodes

type MiddleNodes interface {
	// Middle returns the middle node list or nil.
	MiddleNodes() []any
}

type Node

type Node interface {
	LeftNodes
	MiddleNodes
	RightNodes
}

a uniform node

type Order

type Order func(node any, handler Handler)

type RightNodes

type RightNodes interface {
	// Right returns the middle node list or nil.
	RightNodes() []any
}

Jump to

Keyboard shortcuts

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