Documentation ¶
Index ¶
- func Abs[T constraints.Number](x T) T
- func Clamp[T cmp.Ordered](v, lo, hi T) T
- func Compare[E cmp.Ordered](a E, b E) intdeprecated
- func Dim[T constraints_.Number](x, y T) T
- func IsNaN[E cmp.Ordered](f E) bool
- func IsNewer[T SerialNumber](t1, t2 T) bool
- func Latest[T SerialNumber](s1, s2 T) T
- func Max[T cmp.Ordered](s ...T) T
- func MaxInt[T constraints.Integer]() T
- func Mean[T constraints_.Number, R constraints.Float](s ...T) R
- func Min[T cmp.Ordered](s ...T) T
- func MinInt[T constraints.Integer]() T
- func Reverse[E cmp.Ordered](cmp func(a E, b E) int) func(a E, b E) int
- func RingRem[T constraints.Integer](x, y T) T
- func StandardDeviation[T constraints_.Number, R constraints.Float](s ...T) R
- func Sum[T, R constraints_.Number](s ...T) R
- func Unwrap[T SerialNumber](lastValue int64, value T) int64
- func Variance[T constraints_.Number, R constraints.Float](s ...T) R
- type SerialNumber
- type Unwrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abs ¶ added in v1.2.69
func Abs[T constraints.Number](x T) T
Abs returns the absolute value of last.
func Clamp ¶ added in v1.2.38
Clamp returns the value between boundary [lo,hi], as v < lo ? v : hi > v : hi : v. Reference to lo if v is less than lo, reference to hi if hi is less than v, otherwise reference to v. If v compares equivalent to either bound, returns a reference to v, not the bound.
func Compare
deprecated
added in
v1.2.74
Compare returns an integer comparing two elements. The result will be 0 if a == b, -1 if a < b, and +1 if a > b. This implementation places NaN values before any others, by using:
a < b || (math.IsNaN(a) && !math.IsNaN(b))
Deprecated: Use cmp.Compare instead since go1.21.
func IsNaN ¶ added in v1.2.74
IsNaN is a copy of math.IsNaN to avoid a dependency on the math package.
func IsNewer ¶ added in v1.2.69
func IsNewer[T SerialNumber](t1, t2 T) bool
IsNewer implements RFC 1982: Serial Number Arithmetic See also: https://datatracker.ietf.org/doc/html/rfc1982#section-2 s1 < s2 and (s1 + 1) > (s2 + 1) See also: https://chromium.googlesource.com/external/webrtc/trunk/webrtc/+/f54860e9ef0b68e182a01edc994626d21961bc4b/modules/include/module_common_types.h
func Latest ¶ added in v1.2.69
func Latest[T SerialNumber](s1, s2 T) T
Latest return newer of s1, s2
func MaxInt ¶ added in v1.2.69
func MaxInt[T constraints.Integer]() T
MaxInt returns the largest value representable by the type.
func Mean ¶ added in v1.2.73
func Mean[T constraints_.Number, R constraints.Float](s ...T) R
Mean returns the mean of s.
func MinInt ¶ added in v1.2.69
func MinInt[T constraints.Integer]() T
MinInt returns the smallest value representable by the type.
func RingRem ¶ added in v1.2.68
func RingRem[T constraints.Integer](x, y T) T
RingRem returns the remainder of x looped by +ny until in y > 0 ? [0, y) : (y, 0]. RingRem panics for y == 0 (division by zero). y > 0, then ∈ [0, y) y < 0, then ∈ (y, 0]
func StandardDeviation ¶ added in v1.2.73
func StandardDeviation[T constraints_.Number, R constraints.Float](s ...T) R
StandardDeviation returns the standard deviation of s.
func Unwrap ¶ added in v1.2.69
func Unwrap[T SerialNumber](lastValue int64, value T) int64
Unwrap unwrap a number to a larger type. The numbers will never be unwrapped to a negative value.
func Variance ¶ added in v1.2.73
func Variance[T constraints_.Number, R constraints.Float](s ...T) R
Variance returns the variance of s.
Types ¶
type SerialNumber ¶ added in v1.2.69
type SerialNumber = constraints.Unsigned
SerialNumber is a constraint that permits any unsigned integer type. If future releases of Go add new predeclared unsigned integer types, this constraint will be modified to include them.
type Unwrapper ¶ added in v1.2.69
type Unwrapper[T SerialNumber] struct { // contains filtered or unexported fields }
Unwrapper is an utility class to unwrap a number to a larger type. The numbers will never be unwrapped to a negative value.
func (*Unwrapper[T]) UnwrapWithoutUpdate ¶ added in v1.2.69
UnwrapWithoutUpdate returns the unwrapped value, but don't update the internal state.
func (*Unwrapper[T]) UpdateLast ¶ added in v1.2.69
UpdateLast only update the internal state to the specified last (unwrapped) value.