objtree

package
v0.0.0-...-ee0865d Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteComparator

func ByteComparator(a, b interface{}) int

ByteComparator provides a basic comparison on byte

func Float32Comparator

func Float32Comparator(a, b interface{}) int

Float32Comparator provides a basic comparison on float32

func Float64Comparator

func Float64Comparator(a, b interface{}) int

Float64Comparator provides a basic comparison on float64

func Int16Comparator

func Int16Comparator(a, b interface{}) int

Int16Comparator provides a basic comparison on int16

func Int32Comparator

func Int32Comparator(a, b interface{}) int

Int32Comparator provides a basic comparison on int32

func Int64Comparator

func Int64Comparator(a, b interface{}) int

Int64Comparator provides a basic comparison on int64

func Int8Comparator

func Int8Comparator(a, b interface{}) int

Int8Comparator provides a basic comparison on int8

func IntComparator

func IntComparator(a, b interface{}) int

IntComparator provides a basic comparison on int

func RuneComparator

func RuneComparator(a, b interface{}) int

RuneComparator provides a basic comparison on rune

func StringComparator

func StringComparator(a, b interface{}) int

StringComparator provides a fast comparison on strings

func TimeComparator

func TimeComparator(a, b interface{}) int

TimeComparator provides a basic comparison on time.Time

func UInt16Comparator

func UInt16Comparator(a, b interface{}) int

UInt16Comparator provides a basic comparison on uint16

func UInt32Comparator

func UInt32Comparator(a, b interface{}) int

UInt32Comparator provides a basic comparison on uint32

func UInt64Comparator

func UInt64Comparator(a, b interface{}) int

UInt64Comparator provides a basic comparison on uint64

func UInt8Comparator

func UInt8Comparator(a, b interface{}) int

UInt8Comparator provides a basic comparison on uint8

func UIntComparator

func UIntComparator(a, b interface{}) int

UIntComparator provides a basic comparison on uint

Types

type BFSIterator

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

广度优先搜索

func (*BFSIterator) Depth

func (iter *BFSIterator) Depth() int

获取深度

func (*BFSIterator) Key

func (iter *BFSIterator) Key() string

获取节点的键

func (*BFSIterator) Next

func (iter *BFSIterator) Next() bool

下一个节点

func (*BFSIterator) Parent

func (iter *BFSIterator) Parent() *Node

获取父节点

func (*BFSIterator) Prev

func (iter *BFSIterator) Prev() bool

func (*BFSIterator) Value

func (iter *BFSIterator) Value() interface{}

获取节点的值

type Comparator

type Comparator func(a, b interface{}) int

Comparator will make type assertion (see IntComparator for example), which will panic if a or b are not of the asserted type.

Should return a number:

negative , if a < b
zero     , if a == b
positive , if a > b

type DFSIterator

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

广度优先搜索

func (*DFSIterator) Depth

func (iter *DFSIterator) Depth() int

获取深度

func (*DFSIterator) Key

func (iter *DFSIterator) Key() string

获取节点的键

func (*DFSIterator) Next

func (iter *DFSIterator) Next() bool

func (*DFSIterator) NextJump

func (iter *DFSIterator) NextJump() bool

func (*DFSIterator) NextJumpAddChildren

func (iter *DFSIterator) NextJumpAddChildren() bool

func (*DFSIterator) Node

func (iter *DFSIterator) Node() *Node

func (*DFSIterator) Parent

func (iter *DFSIterator) Parent() *Node

获取父节点

func (*DFSIterator) Prev

func (iter *DFSIterator) Prev() bool

func (*DFSIterator) Value

func (iter *DFSIterator) Value() interface{}

获取节点的值

type Data

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

func NewData

func NewData(key string) *Data

func (*Data) Key

func (d *Data) Key() string

func (*Data) Parent

func (d *Data) Parent() string

func (*Data) SetParent

func (d *Data) SetParent(val string)

func (*Data) SetValue

func (d *Data) SetValue(val interface{})

func (*Data) Value

func (d *Data) Value() interface{}

type IData

type IData interface {
	Key() string
	Parent() string
	Value() interface{}
}

type Node

type Node struct {
	Value    IData
	Children NodeList
	Parent   *Node
	// contains filtered or unexported fields
}

func (*Node) Depth

func (node *Node) Depth() int

type NodeList

type NodeList []*Node

func (*NodeList) Add

func (list *NodeList) Add(node *Node, comparator Comparator)

func (*NodeList) Push

func (list *NodeList) Push(node *Node)

type Tree

type Tree struct {
	Root *Node

	Comparator Comparator
	// contains filtered or unexported fields
}

func NewTree

func NewTree(comparator Comparator) *Tree

func (*Tree) BFSIterator

func (tree *Tree) BFSIterator() BFSIterator

func (*Tree) BFSIteratorNode

func (tree *Tree) BFSIteratorNode(start *Node) BFSIterator

func (*Tree) DFSIterator

func (tree *Tree) DFSIterator() DFSIterator

func (*Tree) DFSIteratorNode

func (tree *Tree) DFSIteratorNode(start *Node) DFSIterator

func (*Tree) Empty

func (tree *Tree) Empty() bool

Empty returns true if tree does not contain any nodes

func (*Tree) Get

func (tree *Tree) Get(key string) IData

func (*Tree) Lookup

func (tree *Tree) Lookup(key string) (*Node, error)

func (*Tree) Print

func (tree *Tree) Print()

func (*Tree) Put

func (tree *Tree) Put(value IData) (node *Node, err error)

func (*Tree) PutData

func (tree *Tree) PutData(key, parent string, val interface{}) (node *Node, err error)

Jump to

Keyboard shortcuts

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