types

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IdTree

type IdTree struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

The IdTree is a collection of Ider objects in a tree structure. Objects must have a unique id within the structure. It is likely that each of your objects will need a pointer to the IdTree to manipulate it, but that is an implementation dependant thing

func NewIdTree

func NewIdTree() *IdTree

func (*IdTree) Add

func (t *IdTree) Add(parent Ider, child Ider)

Add an item to the tree.

func (*IdTree) Children

func (t *IdTree) Children(parent Ider) []Ider

func (*IdTree) Clear

func (t *IdTree) Clear()

func (*IdTree) Get

func (t *IdTree) Get(id string) Ider

func (*IdTree) GetAll

func (t *IdTree) GetAll() []Ider

GetAll returns a list of all the Ider items in the tree. Order is random.

func (*IdTree) Parent

func (t *IdTree) Parent(child Ider) Ider

func (*IdTree) Remove

func (t *IdTree) Remove(item Ider)

Removes the item from the tree and all its sub-itmes

func (*IdTree) RemoveChildren

func (t *IdTree) RemoveChildren(parent Ider)

Remove all child controls

func (*IdTree) Root

func (t *IdTree) Root(child Ider) Ider

Root returns the root of the branch that the given object is on

type Ider

type Ider interface {
	ID() string
}

Any object that returns a string id can be stored in the tree.

type TreeNode

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

A kind of mixin for anything that controls child controls, which are all controls, but also the top level form or page Creates a parent/child tree of controls that is used by the drawing code to draw the controls

func (*TreeNode) AddChildNode

func (n *TreeNode) AddChildNode(c TreeNodeI)

addChildNode adds the given node as a child of the current node

func (*TreeNode) ChildNodes

func (n *TreeNode) ChildNodes() []TreeNodeI

func (*TreeNode) Init

func (n *TreeNode) Init(self TreeNodeI)

To correctly get to the top node, the top node must know about itself

func (*TreeNode) ParentNode

func (n *TreeNode) ParentNode() TreeNodeI

func (*TreeNode) RemoveAllChildNodes

func (n *TreeNode) RemoveAllChildNodes()

func (*TreeNode) RemoveChildNode

func (n *TreeNode) RemoveChildNode(c TreeNodeI)

The central removal function. Manages the entire remove process. Other removal functions should call here.

func (*TreeNode) SetParent

func (n *TreeNode) SetParent(p TreeNodeI)

func (*TreeNode) TopNode

func (n *TreeNode) TopNode() TreeNodeI

Return the top node in the hierarchy.

type TreeNodeI

type TreeNodeI interface {
	AddChildNode(TreeNodeI)
	RemoveAllChildNodes()
	RemoveChildNode(TreeNodeI)
	ParentNode() TreeNodeI
	SetParent(TreeNodeI)
	TopNode() TreeNodeI
	ChildNodes() []TreeNodeI
}

An interface and structure together that can turn any struct into a tree structure with parent/child relationships To use it, simply embed the TreeNode structure into another structure and call Init. This TreeNodeI structure will be convertable to the parent object

Jump to

Keyboard shortcuts

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