utils

package
v0.0.0-...-bf3c7c9 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VisASCII = VisProf{
				// contains filtered or unexported fields
	}
	VisRounded = VisProf{
				// contains filtered or unexported fields
	}
	VisSquare = VisProf{
				// contains filtered or unexported fields
	}
)

Pre-configured visual profiles for trees.

View Source
var ErrNoVis = errors.New("node has no String() method")

ErrNoVis indicates that a node cannot be visualized.

View Source
var ErrNotVisitable = errors.New("object has no Children() method")

ErrNotVisitable indicates that the object cannot be visited.

Functions

func Visit

func Visit(visitable interface{}, visit VisitPred, ctxt interface{}) error

Visit visits every node in a Visitable in depth-first fashion, calling the specified VisitPred with the specified context. If a VisitPred call returns an error, the error is returned.

func Visualize

func Visualize(v interface{}, opts ...VisOption) (string, error)

Visualize constructs a visualization of a tree implementing the Visitable interface.

Types

type FlagSet

type FlagSet interface {
	// FlagName retrieves the name for a flag corresponding to the
	// specified bit.
	FlagName(b uint) string

	// Flags retrieves a list of flags corresponding to the
	// specified bit set.  The flags will be in order from lowest
	// set bit to highest.
	Flags(flags interface{}) []string
}

FlagSet is an interface representing sets of named flags.

type FlagSet16

type FlagSet16 map[uint16]string

FlagSet16 is a mapping from flags to flag names.

func (FlagSet16) FlagName

func (fs FlagSet16) FlagName(b uint) string

FlagName retrieves the name for a flag corresponding to the specified bit.

func (FlagSet16) Flags

func (fs FlagSet16) Flags(flags interface{}) []string

Flags retrieves a list of flags corresponding to the specified bit set. The flags will be in order from lowest set bit to highest.

type FlagSet32

type FlagSet32 map[uint32]string

FlagSet32 is a mapping from flags to flag names.

func (FlagSet32) FlagName

func (fs FlagSet32) FlagName(b uint) string

FlagName retrieves the name for a flag corresponding to the specified bit.

func (FlagSet32) Flags

func (fs FlagSet32) Flags(flags interface{}) []string

Flags retrieves a list of flags corresponding to the specified bit set. The flags will be in order from lowest set bit to highest.

type FlagSet64

type FlagSet64 map[uint64]string

FlagSet64 is a mapping from flags to flag names.

func (FlagSet64) FlagName

func (fs FlagSet64) FlagName(b uint) string

FlagName retrieves the name for a flag corresponding to the specified bit.

func (FlagSet64) Flags

func (fs FlagSet64) Flags(flags interface{}) []string

Flags retrieves a list of flags corresponding to the specified bit set. The flags will be in order from lowest set bit to highest.

type FlagSet8

type FlagSet8 map[uint8]string

FlagSet8 is a mapping from flags to flag names.

func (FlagSet8) FlagName

func (fs FlagSet8) FlagName(b uint) string

FlagName retrieves the name for a flag corresponding to the specified bit.

func (FlagSet8) Flags

func (fs FlagSet8) Flags(flags interface{}) []string

Flags retrieves a list of flags corresponding to the specified bit set. The flags will be in order from lowest set bit to highest.

type VisOption

type VisOption func(opts *visCtxt)

VisOption is an option for the tree visualizer.

func VisPredicate

func VisPredicate(vis VisPred) VisOption

VisPredicate sets the predicate for visualizing a tree node.

func VisProfile

func VisProfile(prof VisProf) VisOption

VisProfile sets the visual profile to use for the visualization.

type VisPred

type VisPred func(v Visitable) (string, error)

VisPred is a predicate function called on a given Visitable to produce a string representation of a single node in a tree.

type VisProf

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

VisProf represents a visual profile for visualizing a tree.

type VisitPred

type VisitPred func(ctxt interface{}, v Visitable, last bool) (interface{}, error)

VisitPred is a predicate function called on each of the child nodes of a Visitable. It is called with a context, the Visitable being visited, and a boolean indicating if the Visitable is the last child of its parent. It should return a context to be passed to the VisitPred for its children and an error.

type Visitable

type Visitable interface {
	// Children returns the list of child nodes.
	Children() []Visitable
}

Visitable is an interface for describing visitable nodes.

Jump to

Keyboard shortcuts

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