it

package module
v0.0.0-...-79bc5e8 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 13 Imported by: 1

README

it

generic immutable tree structure

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound    = errors.New("not found")
	ErrInvalidPath = errors.New("invalid path")
	ErrInvalidName = errors.New("invalid name")
	ErrBadOrder    = errors.New("bad order")
)

Functions

func Compare

func Compare(a, b any) int

func NewNodeID

func NewNodeID() int64

Types

type Comparable

type Comparable interface {
	Cmp(b any) int
}

type Key

type Key any

type KeyPath

type KeyPath []Key

type Node

type Node interface {
	Equal(node Node) bool
	KeyRange() (Key, Key)
	Mutate(
		ctx Scope,
		path KeyPath,
		fn func(Node) (Node, error),
	) (
		retNode Node,
		err error,
	)
	Merge(
		ctx Scope,
		node2 Node,
	) (
		newNode Node,
		err error,
	)
	Dump(w io.Writer, level int)
}

type NodeSet

type NodeSet struct {
	ID     int64
	Nodes  []Node
	MinKey Key
	MaxKey Key
}

func NewNodeSet

func NewNodeSet(nodes []Node) *NodeSet

func (NodeSet) Dump

func (n NodeSet) Dump(w io.Writer, level int)

func (*NodeSet) Equal

func (n *NodeSet) Equal(n2 Node) bool

func (NodeSet) KeyRange

func (n NodeSet) KeyRange() (Key, Key)

func (*NodeSet) Merge

func (n *NodeSet) Merge(ctx Scope, node2 Node) (Node, error)

func (*NodeSet) Mutate

func (n *NodeSet) Mutate(
	ctx Scope,
	path KeyPath,
	fn func(Node) (Node, error),
) (
	retNode Node,
	err error,
)

func (NodeSet) Range

func (n NodeSet) Range(cont Src) Src

type Scope

type Scope = dscope.Scope

type Sink

type Sink = pp.Sink

type Src

type Src = pp.Src

Jump to

Keyboard shortcuts

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