treelinks

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

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 0 Imported by: 1 module, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Links for a tree node, with kids in a linked list, plus UUIDv7. Links are parent, prev-peer, next-peer, first kid, last kid. A tree can be reconstituted by saving only the first three; the last two add redundancy for integrity checking.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsZV

func IsZV[T comparable](arg T) bool

IsZV reports whether arg is the zero value for T. https://www.perplexity.ai/search/717b5c69-194e-4599-88d6-2f00ee7a236a NOTE: "==" works byte-for-byte for UUIDs cos they are an array, not a slice! See https://www.perplexity.ai/search/717b5c69-194e-4599-88d6-2f00ee7a236a .

func NotZV

func NotZV[T comparable](arg T) bool

NotZV reports whether arg is the zero value for T. https://www.perplexity.ai/search/717b5c69-194e-4599-88d6-2f00ee7a236a NOTE: "==" works byte-for-byte for UUIDs cos they are an array, not a slice! See https://www.perplexity.ai/search/717b5c69-194e-4599-88d6-2f00ee7a236a .

func ZV

func ZV[T comparable]() T

ZV returns the zero value for any T. https://www.perplexity.ai/search/717b5c69-194e-4599-88d6-2f00ee7a236a

Types

type Stringser

type Stringser interface {
	Echo() string
	Infos() string
	Debug() string
}

Stringser is copied from github.com/fbaube/stringutils.Stringser to keep out dependencies. Infos is spelled that way cos of a name collision with the stdlib.

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

Treelinks stores a set of links for a tree node embedded in a DB-persistable object. In simplest (and initial) usage, the fields for parent, previous peer, and next peer can be persisted and are sufficient to rebuild a tree when read back in. In later usage, two enhancements are provided for:

  • fields for first kid and last kid can be persisted, which provides redundancy when maintaining and rebuilding a tree, providing robustness.
  • these treelinks can also be provided for other "directions", and not just for the kind of default that grows "downward", as for a filesystem or a markup document. Other directions can support things like incoming links and metadata facets and versions. This concept is being developed under the name "Quadranode".
  • Implementation note: When a tree structure is built that extends upward, with the root at the bottom, maybe some of these field names should be aliased to avoid confusion, since "up" & "down" are reversed, and so are "parent & "kid".

A set of Treelinks has, in additon to the parent and peer links, additional fields:

  • outerOwner, a pointer to the larger struct that embeds the Treelinks; this lets code for maintenance and building and rebuilding focus on just the Treelinks, without worrying about methods "bubbling up" to be methods of enbedding structs.
  • level, a number that starts at zero for the root node.
  • OID is NOT defined here: it is defined "one level up" in package nork, which can manage multiple sets of Treelinks. An OID is a unique identifier and database index and reference, and is discussed in more detail in package [oid].

About the Treelinks:

  • fields Prnt Prev Next are each a single item
  • prnt is for a single parent (iff it fits conceptually) (typ."Up", but gets rendered to the left, like in NexSTEP)
  • kids is ordered child nodes and outgoing links (typ."Down", but gets rendered to the right, like in NexSTEP)
  • usrs is referrers (like in a ToC or ditamap) and incoming links (typ."Up", but gets rendered to the left, like in NexSTEP)
  • tags is metadata tags/facets (gets rendered above) (can include properties ?)
  • vers is previous versions (gets rendered below, as a deck) (done as a list, not a tree)

.

func (*Treelinks) AfterItInsert

func (p *Treelinks) AfterItInsert(p2 Treelinkser)

func (*Treelinks) AppendAllKids

func (p *Treelinks) AppendAllKids(rKids []Treelinkser)

AppendAllKids appends the supplied Kids to the linked list of Kids.

func (*Treelinks) AppendAsLastKid

func (p *Treelinks) AppendAsLastKid(pNewN Treelinkser)

AppendAsLastKid appends a Kid to the linked list of Kids.

func (*Treelinks) BeforeItInsert

func (oldTL *Treelinks) BeforeItInsert(newTL Treelinkser)

func (*Treelinks) FirstKid

func (p *Treelinks) FirstKid() Treelinkser

func (*Treelinks) HasKids

func (p *Treelinks) HasKids() bool

func (*Treelinks) KidsAsSlice

func (p *Treelinks) KidsAsSlice() []Treelinkser

func (*Treelinks) LastKid

func (p *Treelinks) LastKid() Treelinkser

func (*Treelinks) Level

func (p *Treelinks) Level() int

==========================

ONE-LINER ATOMIC METHODS

==========================

func (*Treelinks) LinksPtr

func (p *Treelinks) LinksPtr() *Treelinks

Links (part of interface Treelinkser) gets promoted in embedding structs, so that it can be called on an "outer owning" struct that embeds Treelinks.

func (*Treelinks) Next

func (p *Treelinks) Next() Treelinkser

func (*Treelinks) OuterOwner

func (p *Treelinks) OuterOwner() Treelinkser

func (*Treelinks) Parent

func (p *Treelinks) Parent() Treelinkser

func (*Treelinks) PrependAsFirstKid

func (p *Treelinks) PrependAsFirstKid(pNew0 Treelinkser)

PrependAsFirstKid prepends a Kid to the linked list of Kids.

func (*Treelinks) Prev

func (p *Treelinks) Prev() Treelinkser

func (*Treelinks) ReplaceBy

func (p *Treelinks) ReplaceBy(p2 Treelinkser)

func (*Treelinks) SetLevel

func (p *Treelinks) SetLevel(newL int)

func (*Treelinks) SetNext

func (p *Treelinks) SetNext(newN Treelinkser)

func (*Treelinks) SetOuterOwner

func (p *Treelinks) SetOuterOwner(newOO Treelinkser)

func (*Treelinks) SetParent

func (p *Treelinks) SetParent(newP Treelinkser)

func (*Treelinks) SetPrev

func (p *Treelinks) SetPrev(newP Treelinkser)
func (p *Treelinks) Unlink()

func (*Treelinks) ValidateKids

func (p *Treelinks) ValidateKids() error

type Treelinkser

type Treelinkser interface {

	// ==========================
	//  BASIC, SIMPLE PARENT/KID
	//   INFORMATION AND QUERIES
	//    (getters and setters
	//    have no side effects)
	// ==========================
	Unlink()
	Parent() Treelinkser
	Level() int
	SetParent(Treelinkser)
	SetLevel(newL int)
	HasKids() bool
	FirstKid() Treelinkser
	LastKid() Treelinkser
	OuterOwner() Treelinkser
	SetOuterOwner(newOO Treelinkser)
	LinksPtr() *Treelinks // had omitted this to
	//  avoid type-casting to *Treelinks all the time
	// =======================
	//   PREV & NEXT PEERS
	//   (i.e. SIBLINGS in
	//  LINKED LIST of KIDS)
	//  (getters and setters
	//  have no side effects)
	// =======================
	Prev() Treelinkser
	Next() Treelinkser
	SetPrev(newPrev Treelinkser)
	SetNext(newNext Treelinkser)
	// =========================
	//  ADVANCED KID OPERATIONS
	// =========================
	KidsAsSlice() []Treelinkser
	ValidateKids() error
	// ==================================
	//    COMPLEX KID OPERATIONS that
	//  affect multiple fields and might
	//  need to be placed behind a Mutex
	// ==================================
	PrependAsFirstKid(Treelinkser)
	AppendAsLastKid(Treelinkser)
	AppendAllKids([]Treelinkser)
	ReplaceBy(newTL Treelinkser)
	BeforeItInsert(Treelinkser)
	AfterItInsert(Treelinkser)
}

Jump to

Keyboard shortcuts

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