common

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2018 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const LeafsSize = 32

Variables

View Source
var (
	// ErrAmountUnderflow indicates the value is negative, which is not allowed.
	ErrAmountUnderflow = errors.New("amount: underflow (value is negative)")

	// ErrAmountInvalidString indicates the string is not valid when converted to amount.
	ErrAmountInvalidString = errors.New("amount: invalid string to amount")
)
View Source
var (
	ErrNodeNotFound        = errors.New("ERROR: Node not found in tree")
	ErrCantCreateEmptyNode = errors.New("ERROR: Node index and value must not be empty")
)

Functions

This section is empty.

Types

type Amount

type Amount struct {
	big.Int
}

Amount implements an unsigned integer type with arbitrary/no upper bound. It is based on big.Int.

func NewAmount

func NewAmount(i uint64) *Amount

NewAmount returns a new Amount struct with given an unsigned integer.

func NewAmountFromBigInt

func NewAmountFromBigInt(i *big.Int) (*Amount, error)

NewAmountFromBigInt returns a new Amount struct with given big.Int representation.

func NewAmountFromBytes

func NewAmountFromBytes(b []byte) *Amount

func NewAmountFromString

func NewAmountFromString(s string) (*Amount, error)

NewAmountFromString returns a new Amount struct given string representation of an integer in base 10.

func (*Amount) Add

func (a *Amount) Add(b *Amount) *Amount

Add returns sum of a + b

func (*Amount) BigInt

func (a *Amount) BigInt() *big.Int

Uint64 returns the big.Int representation of the amount.

func (*Amount) Cmp

func (a *Amount) Cmp(b *Amount) int

Cmp compares a and b and returns:

-1 if a <  b
 0 if a == b
+1 if a >  b

func (*Amount) IsZero

func (a *Amount) IsZero() bool

func (*Amount) Sub

func (a *Amount) Sub(b *Amount) (*Amount, error)

Sub returns difference of a - b. Returns nil with ErrAmountUnderflow if the result is negative (a < b)

func (*Amount) Times

func (a *Amount) Times(b uint64) *Amount

Times returns product of a * b where b is uint64

func (*Amount) Validate

func (a *Amount) Validate() error

Validate returns error if a is not a valid amount, otherwise returns nil.

type Entry

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

type Node

type Node struct {
	Entries  []Entry
	Parent   *Node
	Children []*Node
	Height   uint
	// contains filtered or unexported fields
}

entries include the node's entry itself as the first entry and its childrens' entry following

func (*Node) AddChild

func (parent *Node) AddChild(child *Node)

type Test

type Test struct {
	Num uint
}

type Tree

type Tree struct {
	Root      *Node
	MaxHeight uint
	Found     *Node
	Searching bool
	// contains filtered or unexported fields
}

func NewTree

func NewTree(rootNodeIndex interface{}, rootNodeValue interface{}) *Tree

func (*Tree) Get

func (t *Tree) Get(parent *Node, index interface{})

Search from root, use if you have no closer known nodes upstream

func (*Tree) NewNode

func (t *Tree) NewNode(index interface{}, value interface{}) (*Node, error)

func (*Tree) RecursiveFind

func (t *Tree) RecursiveFind(parent *Node, index interface{})

func (*Tree) SearchParentNodeAndAddChild

func (t *Tree) SearchParentNodeAndAddChild(startNode *Node, parentIndex interface{}, childIndex interface{}, childValue interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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