node

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package node provides a small generic tree node used to describe Paper document structure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node[T any] struct {
	// contains filtered or unexported fields
}

Node is a generic tree node.

func New

func New[T any](data T) *Node[T]

New creates a new node with data.

func (*Node[T]) AddNext

func (n *Node[T]) AddNext(child *Node[T])

AddNext adds a child node.

func (*Node[T]) Backtrack

func (n *Node[T]) Backtrack() []*Node[T]

Backtrack returns a path from this node to the root.

func (*Node[T]) Filter

func (n *Node[T]) Filter(filterFunc func(obj T) bool) (*Node[T], bool)

Filter returns a copy of this subtree containing only nodes accepted by filterFunc.

func (*Node[T]) GetData

func (n *Node[T]) GetData() T

GetData returns the node data.

func (*Node[T]) GetID

func (n *Node[T]) GetID() int

GetID returns the node ID.

func (*Node[T]) GetNexts

func (n *Node[T]) GetNexts() []*Node[T]

GetNexts returns the child nodes.

func (*Node[T]) GetPrevious

func (n *Node[T]) GetPrevious() *Node[T]

GetPrevious returns the parent node.

func (*Node[T]) GetStructure

func (n *Node[T]) GetStructure() []string

GetStructure returns parent-child ID pairs for this node and its descendants.

func (*Node[T]) IsLeaf

func (n *Node[T]) IsLeaf() bool

IsLeaf reports whether this node has no children.

func (*Node[T]) IsRoot

func (n *Node[T]) IsRoot() bool

IsRoot reports whether this node has no parent.

func (*Node[T]) WithID

func (n *Node[T]) WithID(id int) *Node[T]

WithID sets the node ID.

Jump to

Keyboard shortcuts

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