func Abs(v int) int
Abs get the absolute value of the integer 'v'.
func Ceil(numerator, denominator int) int
Ceil gets the 'ceil' value for the provided 'numerator' and 'denominator'.
func Max(x, y int) int
Max gets the maximum value from the provided 'x', 'y' arguments.
func Min(x, y int) int
Min gets the minimal value from the provided 'x' and 'y' arguments.
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'.
IntSlice is the integer slice that contains panic safe methods.
type IntSlice []int
func NewIntSlice(i int) *IntSlice
NewIntSlice creates new integer slice.
func (i *IntSlice) Add(v int) error
Add adds the integer 'v' to the slice
func (i *IntSlice) Copy() *IntSlice
Copy creates a copy of given int slice.
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 (i IntSlice) Size() int
Size returns the size of the int slice.
IntsMap is a wrapper over the map[uint64][]int. The 'key' collisions are stored under subsequent slice positions.
type IntsMap map[uint64][]int
func (i IntsMap) Add(key uint64, value int)
Add adds the 'value' to the ints map at the 'key'.
func (i IntsMap) Delete(key uint64)
Delete delete the 'key' records.
func (i IntsMap) Get(key uint64) (int, bool)
Get gets the first int value at the 'key'.
func (i IntsMap) GetSlice(key uint64) ([]int, bool)
GetSlice gets the int slice located at the 'key'.
NumSlice is the slice of the numbers that has a panic safe API.
type NumSlice []float32
func NewNumSlice(i int) *NumSlice
NewNumSlice creates a new NumSlice pointer.
func (n *NumSlice) Add(v float32)
Add adds the float32 'v' value.
func (n *NumSlice) AddInt(v int)
AddInt adds the 'v' integer value to the num slice.
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 (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 (n NumSlice) GetIntSlice() []int
GetIntSlice gets the slice of integers from the provided 'NumSlice' values.
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 (s *Stack) Len() int
Len returns the size of the stack.
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 (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 (s *Stack) Push(v interface{})
Push adds the 'v' element to the top of the stack.