tree

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	Parent      *Element
	ID          int64
	Name        string
	Description string
	Children    []*Element
}

func NewElement

func NewElement(id int64, name, description string) *Element

func (*Element) AddChild

func (ele *Element) AddChild(child *Element)

func (*Element) IsLeaf

func (ele *Element) IsLeaf() bool

func (*Element) RemoveChild

func (ele *Element) RemoveChild(child *Element)

type Tree

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

func Default

func Default() *Tree

func (*Tree) Add

func (t *Tree) Add(ctx context.Context, pid int64, name, description string) (id int64, e error)

func (*Tree) Change

func (t *Tree) Change(ctx context.Context, id int64, name, description string) (changed bool, e error)

func (*Tree) Foreach

func (t *Tree) Foreach(callback func(ele *Element) (e error)) (e error)

func (*Tree) Init

func (t *Tree) Init()

func (*Tree) LastModified

func (t *Tree) LastModified() (modtime time.Time)

func (*Tree) Len

func (t *Tree) Len() int

func (*Tree) Move

func (t *Tree) Move(ctx context.Context, id, pid int64) (changed bool, e error)

func (*Tree) Remove

func (t *Tree) Remove(ctx context.Context, id int64) (rowsAffected int, e error)

Jump to

Keyboard shortcuts

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