Documentation
¶
Index ¶
- func IsZV[T comparable](arg T) bool
- func NotZV[T comparable](arg T) bool
- func ZV[T comparable]() T
- type Stringser
- type Treelinks
- func (p *Treelinks) AfterItInsert(p2 Treelinkser)
- func (p *Treelinks) AppendAllKids(rKids []Treelinkser)
- func (p *Treelinks) AppendAsLastKid(pNewN Treelinkser)
- func (oldTL *Treelinks) BeforeItInsert(newTL Treelinkser)
- func (p *Treelinks) FirstKid() Treelinkser
- func (p *Treelinks) HasKids() bool
- func (p *Treelinks) KidsAsSlice() []Treelinkser
- func (p *Treelinks) LastKid() Treelinkser
- func (p *Treelinks) Level() int
- func (p *Treelinks) LinksPtr() *Treelinks
- func (p *Treelinks) Next() Treelinkser
- func (p *Treelinks) OuterOwner() Treelinkser
- func (p *Treelinks) Parent() Treelinkser
- func (p *Treelinks) PrependAsFirstKid(pNew0 Treelinkser)
- func (p *Treelinks) Prev() Treelinkser
- func (p *Treelinks) ReplaceBy(p2 Treelinkser)
- func (p *Treelinks) SetLevel(newL int)
- func (p *Treelinks) SetNext(newN Treelinkser)
- func (p *Treelinks) SetOuterOwner(newOO Treelinkser)
- func (p *Treelinks) SetParent(newP Treelinkser)
- func (p *Treelinks) SetPrev(newP Treelinkser)
- func (p *Treelinks) Unlink()
- func (p *Treelinks) ValidateKids() error
- type Treelinkser
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 ¶
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 ¶
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) KidsAsSlice ¶
func (p *Treelinks) KidsAsSlice() []Treelinkser
func (*Treelinks) LastKid ¶
func (p *Treelinks) LastKid() Treelinkser
func (*Treelinks) Level ¶
==========================
ONE-LINER ATOMIC METHODS
==========================
func (*Treelinks) LinksPtr ¶
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) 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 (*Treelinks) ValidateKids ¶
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)
}