Documentation ¶
Overview ¶
Package ints provides a standard Inter interface and basic functions defined on Inter types that support core things like Max, Min, Abs. Furthermore, fully generic slice sort and conversion methods in the kit type kit package attempt to use this interface, before falling back on reflection. If you have a struct that can be converted into an int64, then this is the only way to allow it to be sorted using those generic functions, as the reflect.Kind fallback will fail.
It also includes Max, Min, Abs for builtin int64, int32 types.
Index ¶
- func Abs(a Inter) int64
- func Abs32(a int32) int32
- func Abs64(a int64) int64
- func AbsInt(a int) int
- func ClipInt(a, min, max int) int
- func IntMultiple(val, mod int) int
- func Max32(a, b int32) int32
- func Max64(a, b int64) int64
- func MaxInt(a, b int) int
- func Min32(a, b int32) int32
- func Min64(a, b int64) int64
- func MinInt(a, b int) int
- type IntSetter
- type Inter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClipInt ¶ added in v1.1.6
ClipInt clips int within min, max range (max exclusive, min inclusive)
func IntMultiple ¶ added in v1.1.10
IntMultiple returns the interger multiple of mod that is always >= given value: int(Ceil(val / mod)) * mod
Types ¶
type IntSetter ¶
IntSetter is an Inter that can also be set from an int. Satisfying this interface requires a pointer to the underlying type.