tree

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddChild

func AddChild(parent *Node, child *Node)

Inserts child node into parent node. Parent will point to child and child will point to parent EXCEPT when parent is a TAG node. If parent is a Tag node, child should not point back to parent as URL nodes should always point to folder parent nodes only.

func FindNode

func FindNode(node *Node, root *Node) bool

Finds a node and the tree starting at root

func FindNodeByName

func FindNodeByName(name string, root *Node) bool

func MapNodeFunc

func MapNodeFunc(node *Node, nType NodeType, f func(*Node))

Maps a func(*Node) to any node in the tree starting from node that matches the type nType

func PrintTree

func PrintTree(root *Node)

func WalkBuildIndex

func WalkBuildIndex(node *Node, index index.HashTree)

Rebuilds the memory url index after parsing all bookmarks. Keeps memory index in sync with last known state of browser bookmarks

Types

type Node

type Node struct {
	Title      string
	Type       NodeType // folder, tag, url
	URL        string
	Tags       []string
	Desc       string
	Module     string
	HasChanged bool
	NameHash   uint64 // hash of the metadata
	Parent     *Node
	Children   []*Node
}

A tree node

func Ancestor

func Ancestor(node *Node) *Node

Returns the ancestor of this node

func FindParents

func FindParents(root *Node, url *Node, nt NodeType) []*Node

Recursively traverse the tree from a root and find all occurences of [url] whose parent is a folder without using url.Parent as a reference Returns a list of nodes that match the criteria

func (*Node) DirectChildOf

func (node *Node) DirectChildOf(parent *Node) bool

func (*Node) GetBookmark

func (node *Node) GetBookmark() *gosuki.Bookmark

func (*Node) GetFolderParents

func (node *Node) GetFolderParents() []*Node

Get all parents for node by traversing from leaf to root

func (*Node) GetRoot

func (node *Node) GetRoot() *Node

type NodeType

type NodeType int
const (
	RootNode NodeType = iota
	URLNode
	FolderNode
	TagNode
)

Jump to

Keyboard shortcuts

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