mtree

package
v2.2.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package mtree provides advanced tools for encoding tree paths in a material format

Index

Constants

View Source
const PRECISION = 100

Variables

This section is empty.

Functions

func CommonPrefix added in v1.5.0

func CommonPrefix(sep byte, paths ...string) string

func ToPath

func ToPath(f *Fraction) string

ToPath a Fraction

func ToPathUint

func ToPathUint(f *Fraction) []uint64

Types

type Float

type Float struct {
	*big.Float
}

Float type

func NewFloat

func NewFloat() *Float

NewFloat returns a big Float with a 512 precision

func (*Float) Nat

func (f *Float) Nat() Nat

Nat representation of a float

type Fraction

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

Fraction type

func NewFraction

func NewFraction(n *big.Int, d *big.Int) *Fraction

NewFraction from a numerator and denominator

func NewFractionFromMaterializedPath

func NewFractionFromMaterializedPath(path ...uint64) *Fraction

NewFractionFromMaterializedPath function

func (Fraction) Decimal

func (f Fraction) Decimal() *big.Rat

Decimal representation of the fraction

func (Fraction) Den

func (f Fraction) Den() *big.Int

Den value of the fraction

func (Fraction) Num

func (f Fraction) Num() *big.Int

Num value of the fraction

type MPath

type MPath []uint64

MPath type struct

func NewMPath

func NewMPath(mpath ...uint64) MPath

NewMPath from mpath

func NewMPathFromMPath

func NewMPathFromMPath(b MPath) MPath

NewMPathFromMPath returns a copy of a slice

func (MPath) CommonRoot

func (m MPath) CommonRoot(m2 MPath) MPath

func (MPath) Hash

func (m MPath) Hash() uint32

func (MPath) Index

func (m MPath) Index() uint64

func (MPath) Parent

func (m MPath) Parent() MPath

Parent of a specific path

func (MPath) Parents

func (m MPath) Parents() []MPath

func (MPath) Rat

func (m MPath) Rat() *Rat

Rat representation of a materialized path

func (MPath) Sibling

func (m MPath) Sibling() MPath

Sibling of a specific path

func (MPath) String

func (m MPath) String() string

String representation of a mpath

type MPathProvider

type MPathProvider interface {
}

type Matrix

type Matrix [][]*big.Int

func MoveSubtree

func MoveSubtree(p0 *Matrix, m *big.Int, p1 *Matrix, n *big.Int, M *Matrix) *Matrix

func NewMatrix

func NewMatrix(m00 *big.Int, m01 *big.Int, m10 *big.Int, m11 *big.Int) *Matrix

func (Matrix) GetA11

func (m Matrix) GetA11() *big.Int

func (Matrix) GetA12

func (m Matrix) GetA12() *big.Int

func (Matrix) GetA21

func (m Matrix) GetA21() *big.Int

func (Matrix) GetA22

func (m Matrix) GetA22() *big.Int

type Nat

type Nat []big.Word

An unsigned integer x of the form

x = x[n-1]*_B^(n-1) + x[n-2]*_B^(n-2) + ... + x[1]*_B + x[0]

with 0 <= x[i] < _B and 0 <= i < n is stored in a slice of length n, with the digits x[i] as the slice elements.

A number is normalized if the slice contains no leading 0 digits. During arithmetic operations, denormalized values may occur but are always normalized before returning the final result. The normalized representation of 0 is the empty or nil slice (length = 0).

type Rat

type Rat struct {
	*big.Rat
}

Float type

func NewRat

func NewRat() *Rat

func (*Rat) SetMPath

func (f *Rat) SetMPath(path ...uint64) *Rat

SetMPath sets the value of the float based on the materialized path given

type TreeNode

type TreeNode struct {
	*tree.Node

	MPath MPath
	//rat   *Rat
	//srat  *Rat
	Level int
	// contains filtered or unexported fields
}

TreeNode definition

func NewTreeNode

func NewTreeNode() *TreeNode

NewTreeNode wraps a node with its rational equivalent of the mpath

func (*TreeNode) GetMeta

func (t *TreeNode) GetMeta(name string, value interface{})

GetMeta gets a meta from a meta store using the lock

func (*TreeNode) Name

func (t *TreeNode) Name() string

Name from the metastore (uses a rwlock)

func (*TreeNode) SetMPath

func (t *TreeNode) SetMPath(mpath ...uint64)

SetMPath triggers the calculation of the rat representation and the sibling rat representation for the node

func (*TreeNode) SetMeta

func (t *TreeNode) SetMeta(name string, value interface{})

SetMeta sets a meta using a lock

func (*TreeNode) SetName

func (t *TreeNode) SetName(name string)

SetName records the name of the node in the metastore (uses a lock)

Jump to

Keyboard shortcuts

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