tree

package
v0.0.0-...-fb70a81 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TreeNode

type TreeNode struct {
	Value       int
	Left, Right *TreeNode
}

func CreateNode

func CreateNode(value int) *TreeNode

定义工厂函数 可返回局部变量的地址

func (TreeNode) Print

func (node TreeNode) Print()

定义一个函数 xxx 指定外部对象调用,相当于其他语言的 this.xxx() node 为接收者 print 为调用方法

func (*TreeNode) SetValue

func (node *TreeNode) SetValue(value int)

go 语言都是值传递 所以需要将指针传递进去 外部调用方依然是 node.setValue() 外部不需要再转成指针形式 要改变类型必须使用指针接收着 结构过大也考虑使用指针接收者 一致性:如有指针接收者,最好都是指针接收者

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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