HomeUniDoc
...

Package basic

Overview ▾

Package basic contains common structures, slices and maps used within the jbig2 package.

func Abs

func Abs(v int) int

Abs get the absolute value of the integer 'v'.

func Ceil

func Ceil(numerator, denominator int) int

Ceil gets the 'ceil' value for the provided 'numerator' and 'denominator'.

func Max

func Max(x, y int) int

Max gets the maximum value from the provided 'x', 'y' arguments.

func Min

func Min(x, y int) int

Min gets the minimal value from the provided 'x' and 'y' arguments.

func Sign

func Sign(v float32) float32

Sign gets the float32 sign of the 'v' value. If the value 'v' is greater or equal to 0.0 the function returns 1.0. Otherwise it returns '-1.0'.

type IntSlice

IntSlice is the integer slice that contains panic safe methods.

type IntSlice []int

func NewIntSlice

func NewIntSlice(i int) *IntSlice

NewIntSlice creates new integer slice.

func (*IntSlice) Add

func (i *IntSlice) Add(v int) error

Add adds the integer 'v' to the slice

func (*IntSlice) Copy

func (i *IntSlice) Copy() *IntSlice

Copy creates a copy of given int slice.

func (IntSlice) Get

func (i IntSlice) Get(index int) (int, error)

Get gets the integer at 'index'. Returns error if the index is out of range or given integer doesn't exists.

func (IntSlice) Size

func (i IntSlice) Size() int

Size returns the size of the int slice.

type IntsMap

IntsMap is a wrapper over the map[uint64][]int. The 'key' collisions are stored under subsequent slice positions.

type IntsMap map[uint64][]int

func (IntsMap) Add

func (i IntsMap) Add(key uint64, value int)

Add adds the 'value' to the ints map at the 'key'.

func (IntsMap) Delete

func (i IntsMap) Delete(key uint64)

Delete delete the 'key' records.

func (IntsMap) Get

func (i IntsMap) Get(key uint64) (int, bool)

Get gets the first int value at the 'key'.

func (IntsMap) GetSlice

func (i IntsMap) GetSlice(key uint64) ([]int, bool)

GetSlice gets the int slice located at the 'key'.

type NumSlice

NumSlice is the slice of the numbers that has a panic safe API.

type NumSlice []float32

func NewNumSlice

func NewNumSlice(i int) *NumSlice

NewNumSlice creates a new NumSlice pointer.

func (*NumSlice) Add

func (n *NumSlice) Add(v float32)

Add adds the float32 'v' value.

func (*NumSlice) AddInt

func (n *NumSlice) AddInt(v int)

AddInt adds the 'v' integer value to the num slice.

func (NumSlice) Get

func (n NumSlice) Get(i int) (float32, error)

Get the float32 value at 'i' index. Returns error if the index 'i' is out of range.

func (NumSlice) GetInt

func (n NumSlice) GetInt(i int) (int, error)

GetInt gets the integer value at the 'i' position. The functions return errors if the index 'i' is out of range. Returns '0' on error.

func (NumSlice) GetIntSlice

func (n NumSlice) GetIntSlice() []int

GetIntSlice gets the slice of integers from the provided 'NumSlice' values.

type Stack

Stack is the LIFO data structure implementation

type Stack struct {
    // Data keeps the stack's values.
    Data []interface{}
    // Aux is the auxiliary additional stack use for some helpers.
    Aux *Stack
}

func (*Stack) Len

func (s *Stack) Len() int

Len returns the size of the stack.

func (*Stack) Peek

func (s *Stack) Peek() (v interface{}, ok bool)

Peek returns the top element of the stack 's'. returns false if the stack is zero length.

func (*Stack) Pop

func (s *Stack) Pop() (v interface{}, ok bool)

Pop the top element of the slack and returns it. Returns false if the stack is 'zero' length.

func (*Stack) Push

func (s *Stack) Push(v interface{})

Push adds the 'v' element to the top of the stack.