Documentation ¶
Index ¶
- Variables
- func DivideInt64(dividend, divisor int64) (quotient, remainder int64)
- func DivmodInt64(numerator, denominator int64) (quotient, remainder int64)
- func FloorMostSignificant(valOriginal int64) int64
- func IntLen(i int) int
- func IntsToInt32s(ints []int) []int32
- func IntsToUints(ints []int) []uint
- func IsEven(i int) bool
- func IsOdd(i int) bool
- func IsOverlapSortedInt(x1, x2, y1, y2 int) bool
- func IsOverlapSortedInt32(x1, x2, y1, y2 int32) bool
- func IsOverlapSortedInt64(x1, x2, y1, y2 int64) bool
- func IsOverlapUnsortedInt(x1, x2, y1, y2 int) bool
- func MinMaxInt32(vals ...int32) (int32, int32)
- func MinMaxUint(vals ...uint) (uint, uint)
- func ModInt(a, b int) int
- func ModInt64(a, b int64) int64
- func PercentChangeToXoX(v float64) float64
- func PrettyTicks(estimatedTickCount int, low, high int64) []int64
- func PrettyTicksPercent(estimatedTickCount int, low, high float64, sigDigits uint8) []float64
- func Round(x float64) float64
- func RoundMore(val float64, roundOn float64, places int) (newVal float64)
- type RangeFloat64
- type RangeInt64
- type SliceFloat64
- func (sf64 *SliceFloat64) Append(num float64)
- func (sf64 *SliceFloat64) Average() (float64, error)
- func (sf64 *SliceFloat64) BuildStats() (SliceFloat64Stats, error)
- func (sf64 *SliceFloat64) Len() int
- func (sf64 *SliceFloat64) Max() (float64, error)
- func (sf64 *SliceFloat64) Mean() (float64, error)
- func (sf64 *SliceFloat64) Median() (float64, error)
- func (sf64 *SliceFloat64) Min() (float64, error)
- func (sf64 *SliceFloat64) Sort()
- func (sf64 *SliceFloat64) Sum() (float64, error)
- type SliceFloat64Stats
- type SliceInt
- func (sint *SliceInt) Append(num int)
- func (sint *SliceInt) Average() (float64, error)
- func (sint *SliceInt) BuildStats() (SliceIntStats, error)
- func (sint *SliceInt) Len() int
- func (sint *SliceInt) Max() (int, error)
- func (sint *SliceInt) Mean() (float64, error)
- func (sint *SliceInt) Median() (int, error)
- func (sint *SliceInt) Min() (int, error)
- func (sint *SliceInt) Sort()
- func (sint *SliceInt) Sum() (int, error)
- type SliceIntStats
Constants ¶
This section is empty.
Variables ¶
var MaxTries = int32(100000)
Functions ¶
func DivideInt64 ¶
DivideInt64 performs integer division, returning a quotient and remainder.
func DivmodInt64 ¶
DivmodInt64 from https://stackoverflow.com/a/43945812
func FloorMostSignificant ¶
FloorMostSignificant returns number with a single significant digit followed by zeros. The value returned is always lower than the supplied value.
func IntsToInt32s ¶
func IntsToUints ¶
func IsOverlapSortedInt ¶
func IsOverlapSortedInt32 ¶
func IsOverlapSortedInt64 ¶
func IsOverlapUnsortedInt ¶
func MinMaxInt32 ¶
MinMaxInt32 returns min/max value given a slice of input values.
func MinMaxUint ¶
MinMaxUint returns min/max value given a slice of input values.
func PercentChangeToXoX ¶
PercentChangeToXoX converts a 1.0 == 100% based `float64` to a XoX percentage `float64`.
func PrettyTicks ¶
PrettyTicks returns a slice of integers that start lower and end higher than the supplied range. This is intended to be used for chart axis.
func PrettyTicksPercent ¶
func Round ¶
Round returns the nearest integer, rounding half away from zero. This function is available natively in Go 1.10
Special cases are:
Round(±0) = ±0 Round(±Inf) = ±Inf Round(NaN) = NaN
This function is from the following gist by gdm85: https://gist.github.com/gdm85/44f648cc97bb3bf847f21c87e9d19b2d
Types ¶
type RangeFloat64 ¶
type RangeFloat64 struct { Min float64 Max float64 Cells int32 // contains filtered or unexported fields }
RangeFloat64 creates a range with a fixed set of cells and returns the cell for a certain value.
func (*RangeFloat64) CellIndexForValue ¶
func (rng *RangeFloat64) CellIndexForValue(v float64) (int32, error)
CellIndexForValue returns a cell index for a requested value.
func (*RangeFloat64) CellMinMax ¶
func (rng *RangeFloat64) CellMinMax(idx int32) (float64, float64, error)
type RangeInt64 ¶
type RangeInt64 struct { Min int64 Max int64 Cells int32 // contains filtered or unexported fields }
RangeFloat64 creates a range with a fixed set of cells and returns the cell for a certain value.
func (*RangeInt64) CellIndexForValue ¶
func (rng *RangeInt64) CellIndexForValue(v int64) (int32, error)
CellIndexForValue returns a cell index for a requested value.
func (*RangeInt64) CellMinMax ¶
func (rng *RangeInt64) CellMinMax(idx int32) (int64, int64, error)
func (*RangeInt64) CellRange ¶
func (rng *RangeInt64) CellRange() (int64, error)
type SliceFloat64 ¶
type SliceFloat64 struct { Elements []float64 Stats SliceFloat64Stats }
SliceFloat64 represets a slice of integers and provides functions on that slice.
func NewSliceFloat64 ¶
func NewSliceFloat64() SliceFloat64
NewSliceFloat64 creates and returns an empty SliceFloat64 struct.
func (*SliceFloat64) Append ¶
func (sf64 *SliceFloat64) Append(num float64)
Append adds an element to the float64 slice.
func (*SliceFloat64) Average ¶
func (sf64 *SliceFloat64) Average() (float64, error)
Average is an alias for Mean.
func (*SliceFloat64) BuildStats ¶
func (sf64 *SliceFloat64) BuildStats() (SliceFloat64Stats, error)
BuildStats builds a stats struct for current float64 slice elements.
func (*SliceFloat64) Len ¶
func (sf64 *SliceFloat64) Len() int
Len returns the number of items in the float64 slice.
func (*SliceFloat64) Max ¶
func (sf64 *SliceFloat64) Max() (float64, error)
Max returns the maximum element value in the float64 slice.
func (*SliceFloat64) Mean ¶
func (sf64 *SliceFloat64) Mean() (float64, error)
Mean returns the arithmetic mean of the float64 slice.
func (*SliceFloat64) Median ¶
func (sf64 *SliceFloat64) Median() (float64, error)
Median returns the median or middle value of the sorted float64 slice.
func (*SliceFloat64) Min ¶
func (sf64 *SliceFloat64) Min() (float64, error)
Min returns the minimum element value in the float64 slice.
func (*SliceFloat64) Sort ¶
func (sf64 *SliceFloat64) Sort()
Sort sorts the elements in the float64 slice.
func (*SliceFloat64) Sum ¶
func (sf64 *SliceFloat64) Sum() (float64, error)
Sum returns sum of all the elements in the float64 slice.
type SliceFloat64Stats ¶
type SliceFloat64Stats struct { Len int Max float64 Mean float64 Median float64 Min float64 Sum float64 }
SliceFloat64Stats represents a set of statistics for a set of float64s.
func NewSliceFloat64Stats ¶
func NewSliceFloat64Stats() SliceFloat64Stats
NewSliceFloat64Stats returns a new initialized SliceFloat64Stats struct.
type SliceInt ¶
type SliceInt struct { Elements []int Stats SliceIntStats }
SliceInt represets a slice of integers and provides functions on that slice.
func NewSliceInt ¶
func NewSliceInt() SliceInt
NewSliceInt creates and returns an empty SliceInt struct.
func (*SliceInt) BuildStats ¶
func (sint *SliceInt) BuildStats() (SliceIntStats, error)
BuildStats builds a stats struct for current integer slice elements.
type SliceIntStats ¶
SliceIntStats represents a set of statistics for a set of integers.
func NewSliceIntStats ¶
func NewSliceIntStats() SliceIntStats
NewSliceIntStats returns a new initialized SliceIntStats struct.