tree

package module
v0.0.0-...-f32e3a4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Walker

func Walker[T any, ID comparable, A ~func() Searchable[T, ID]](root Nodable[T, ID], nextNodesCb SearchableCallBack[T, ID], alg A)

Types

type FlatIndex

type FlatIndex[T any, ID comparable] struct {
	// contains filtered or unexported fields
}

func (*FlatIndex[T, ID]) BuildIndex

func (fi *FlatIndex[T, ID]) BuildIndex(root Nodable[T, ID])

func (FlatIndex[T, ID]) Query

func (fi FlatIndex[T, ID]) Query(query ID) (Nodable[T, ID], error)

type IndexableNode

type IndexableNode[T any, N any, ID comparable] interface {
	BuildIndex(root Nodable[N, ID])
	Query(query T) (Nodable[N, ID], error)
}

type MutableNode

type MutableNode[T any, ID comparable] interface {
	Nodable[T, ID]
	AddNode(node ...Nodable[T, ID])
	DeleteNode(node ...string)
}

type Nodable

type Nodable[T any, ID comparable] interface {
	GetID() ID
	GetChilds() map[ID]Nodable[T, ID]
	GetValue() T
}

func NewNode

func NewNode[T any, ID comparable](id ID, value T, childs ...Nodable[T, ID]) Nodable[T, ID]

type Node

type Node[T any, ID comparable] struct {
	ID    ID                    `yaml:"id" json:"id"`
	Nodes map[ID]Nodable[T, ID] `yaml:"nodes" json:"nodes"`
	Value T
}

func (*Node[T, ID]) AddNode

func (bn *Node[T, ID]) AddNode(node ...Nodable[T, ID])

func (*Node[T, ID]) DeleteNode

func (bn *Node[T, ID]) DeleteNode(node ...ID)

func (Node[T, ID]) GetChilds

func (bn Node[T, ID]) GetChilds() map[ID]Nodable[T, ID]

func (Node[T, ID]) GetID

func (bn Node[T, ID]) GetID() ID

func (Node[T, ID]) GetValue

func (bn Node[T, ID]) GetValue() T

func (*Node[T, ID]) Walk

func (bn *Node[T, ID]) Walk(alg Searchable[T, ID], cb SearchableCallBack[T, ID])

type NodeIndex

type NodeIndex map[string]string

type Searchable

type Searchable[T any, ID comparable] interface {
	Walk(root Nodable[T, ID], cb SearchableCallBack[T, ID])
}

func LevelOrderSearch

func LevelOrderSearch[T any, ID comparable]() Searchable[T, ID]

type SearchableCallBack

type SearchableCallBack[T any, ID comparable] func(node Nodable[T, ID]) error

type SearchableFunc

type SearchableFunc[T any, ID comparable] func(root Nodable[T, ID], cb SearchableCallBack[T, ID])

func (SearchableFunc[T, ID]) Walk

func (sf SearchableFunc[T, ID]) Walk(root Nodable[T, ID], cb SearchableCallBack[T, ID])

Jump to

Keyboard shortcuts

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