Documentation ¶
Overview ¶
Helper functions for handling integers.
Index ¶
- func Contains(slice []int, s int) bool
- func Cumsum(slice []int) []int
- func Delta(ints []int) []int
- func Diff(a, b []int) []int
- func FindIndex(slice []int, val int) (int, bool)
- func FindMissingIndexes(newslice []int, slice []int) (idx []int)
- func GetIndex(slice []int, val int) int
- func Insert(slice []int, idx int, val int) []int
- func Max(a int, b int) int
- func Min(a int, b int) int
- func NumRange(start int, end int, step int) (numberrange []int)
- func RandRange(min int, max int) int
- func Remove(slice []int, s int) []int
- func RemoveFrom(slice []int, s int) []int
- func ReplaceNil(val int, i *int) int
- func Select(condition bool, i1, i2 int) int
- func SetDefault(defaultval int, confval int) int
- func SliceOf(value int, size int) []int
- func SwitchIf(condition bool, i1, i2 int) (int, int)
- func Unique(t []int) []int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delta ¶
Returns the delta between all consecutive ints. Returned slice length is one item shorter.
func FindIndex ¶
Finds the index of first occurrence of the given value and returns the index and a boolean. Boolean is true when index is found, otherwise index = -1.
func FindMissingIndexes ¶
Compares <newslice> against <slice>. Those numbers' indexes from <slice> are collected which are not found from <newslice>.
func GetIndex ¶ added in v0.24.0
Finds the index of first occurrence of the given value and returns the index. If not found index = -1.
func NumRange ¶ added in v0.16.0
Returns an evenly spaced slice of integers, between <start> and <end> with spacing <step>.
func RemoveFrom ¶ added in v0.2.3
RemoveFrom removes an integer from given index
func ReplaceNil ¶ added in v0.22.0
Replaces nil valued *int with given integer
func SetDefault ¶
Replaces default value for a parameter, if the configuration value is zero (ie. initialized empty variable). Note that the function does not make any difference, if the configuration is set to zero on purpose.
Types ¶
This section is empty.