common

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

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")
	ErrChildNodeAlreadyHasParent = errors.New("ERROR: Adding parent to node already with parent")
)

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 Tree

type Tree struct {
	Parent   *Tree
	Children []*Tree
	// contains filtered or unexported fields
}

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

func NewTree

func NewTree(index interface{}, value interface{}) (*Tree, error)

func (*Tree) AddChild added in v0.1.2

func (parent *Tree) AddChild(child *Tree)

func (*Tree) AddParent added in v0.1.2

func (child *Tree) AddParent(parent *Tree) error

func (*Tree) Delete added in v0.1.2

func (t *Tree) Delete()

func (*Tree) FindHeightestChild added in v0.1.2

func (t *Tree) FindHeightestChild(path *Tree, prevDeep, deepest int) (deep int, deepPath *Tree)

func (*Tree) GetKey added in v0.1.2

func (t *Tree) GetKey() interface{}

func (*Tree) GetParentTreesRange added in v0.1.2

func (t *Tree) GetParentTreesRange(head *Tree) []*Tree

func (*Tree) GetValue added in v0.1.2

func (t *Tree) GetValue() interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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