traversal

package
v1.2.77 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 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 interface{}, 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 interface{}, 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 interface{}, 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 interface{}, 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 interface{}, 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 interface{}, 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 interface{}, depth int) (goon bool)
}

type HandlerFunc

type HandlerFunc func(node interface{}, 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 interface{}, depth int) (goon bool)

ServeHTTP calls f(w, r).

type LeftNodes

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

type MiddleNodes

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

type Node

type Node interface {
	LeftNodes
	MiddleNodes
	RightNodes
}

a uniform node

type Order

type Order func(node interface{}, handler Handler)

type RightNodes

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

Jump to

Keyboard shortcuts

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