Documentation ¶
Index ¶
- Variables
- func Abs[D Numeric](v D) D
- func Acos[D Numeric](rad D) D
- func Asin[D Numeric](rad D) D
- func Assert(condition bool, messageFormat string, args ...any)
- func Atan2[D Numeric](y D, x D) D
- func Ceil[D Numeric](v D) D
- func Choose[D Integer](n D, m D) D
- func Clamp[D Numeric](v D, min D, max D) D
- func Clone[V any](nilable *V) *V
- func Coalesce[V any](nilable *V, nonNil V) V
- func Coalesce2[V any](nilable1 *V, nilable2 *V, nonNil V) V
- func CoalesceJoin[V any](a, b V, swap bool, isNil func(V) bool, join func(V, V) V) V
- func Copy(dst any, src any)
- func CopySign[D Numeric](value D, sign D) D
- func Cos[D Numeric](rad D) D
- func CosSin[D Numeric](rad D) (cos D, sin D)
- func Delta[D Numeric](start, end, value D) float32
- func Div[D Numeric](a D, b D) D
- func Down[D Numeric](v D) D
- func Equal[D Numeric](a, b D) bool
- func Factorial[D Numeric](x D) D
- func Floor[D Numeric](v D) D
- func Gcd[D Integer](a D, b D) D
- func If[V any](condition bool, trueValue, falseValue V) V
- func Lerp[D Numeric](start, end D, delta float32) D
- func MapKeys[K comparable, V any](m map[K]V) []K
- func MapValues[K comparable, V any](m map[K]V) []V
- func Max[D Numeric](a D, b D) D
- func MaxMagnitude[D Numeric](value D, max D) D
- func Min[D Numeric](a D, b D) D
- func MinMagnitude[D Numeric](value D, min D) D
- func MinMax[D Numeric](a D, b D) (D, D)
- func Pow[D Numeric](x, y D) D
- func QuadraticFormula(a, b, c, none float32) float32
- func Sign[D Numeric](v D) int
- func Sin[D Numeric](rad D) D
- func SliceAppendAt[D any](target []D, at int, values []D) []D
- func SliceCopy[E any](slice []E) []E
- func SliceEnsureSize[V any](slice []V, size int) []V
- func SliceIndexOf[V comparable](slice []V, value V) int
- func SliceMap[S any, T any](source []S, transform func(value S) T) []T
- func SliceMove[V any](slice []V, from, to int)
- func SliceRemove[E comparable](slice []E, value E) []E
- func SliceRemoveAt[E any](slice []E, index int) []E
- func SliceRemoveAtReplace[E any](slice []E, index int) []E
- func SliceResize[V any](slice []V, size int) []V
- func SliceReverse[E any](s []E)
- func SliceSorted[E any](slice []E, isLess func(E, E) bool) []E
- func Sq[D Numeric](x D) D
- func Sqrt[D Numeric](v D) D
- func Up[D Numeric](v D) D
- type Flags
- type Incrementor
- type Integer
- type Match
- func MatchAll[T constraints.Integer | constraints.Unsigned](test T) Match[T]
- func MatchAlways[T constraints.Integer | constraints.Unsigned]() Match[T]
- func MatchAnd[T constraints.Integer | constraints.Unsigned](ands ...Match[T]) Match[T]
- func MatchAny[T constraints.Integer | constraints.Unsigned](test T) Match[T]
- func MatchEmpty[T constraints.Integer | constraints.Unsigned]() Match[T]
- func MatchExact[T constraints.Integer | constraints.Unsigned](test T) Match[T]
- func MatchNone[T constraints.Integer | constraints.Unsigned](test T) Match[T]
- func MatchNot[T constraints.Integer | constraints.Unsigned](not Match[T]) Match[T]
- func MatchOnly[T constraints.Integer | constraints.Unsigned](test T) Match[T]
- func MatchOr[T constraints.Integer | constraints.Unsigned](ors ...Match[T]) Match[T]
- type Numeric
Constants ¶
This section is empty.
Variables ¶
var EPSILON = float32(0.00001)
Functions ¶
func Choose ¶
func Choose[D Integer](n D, m D) D
Computes the number of combinations of size m that can be made with n things.
func Clamp ¶
func Clamp[D Numeric](v D, min D, max D) D
Returns v but no larger than the max or smaller than the min.
func CoalesceJoin ¶
func CopySign ¶
func CopySign[D Numeric](value D, sign D) D
Returns "value" with the sign of the value "sign"
func CosSin ¶
func CosSin[D Numeric](rad D) (cos D, sin D)
Returns the cosine & sine of the given radians.
func Delta ¶
Computes the delta of v between a start and end value where a delta of 0 is at start and a delta of 1 is at end.
func Down ¶
func Down[D Numeric](v D) D
Rounds the value to the smallest absolute value. Down(4.5)=4, Down(-4.5)=-4, Down(3)=3
func Factorial ¶
func Factorial[D Numeric](x D) D
Computes the factorial of the given number. ex: Factorial(5) = 5*4*3*2*1
func Gcd ¶
func Gcd[D Integer](a D, b D) D
Calculates the greatest common denominator between two integer numbers.
func MapKeys ¶
func MapKeys[K comparable, V any](m map[K]V) []K
func MapValues ¶
func MapValues[K comparable, V any](m map[K]V) []V
func MaxMagnitude ¶
func MaxMagnitude[D Numeric](value D, max D) D
Constrains the absolute value of `value` to be no larger than max.
func MinMagnitude ¶
func MinMagnitude[D Numeric](value D, min D) D
Constrains the absolute value of `value` to be no smaller than min (unless value is zero)
func MinMax ¶
func MinMax[D Numeric](a D, b D) (D, D)
Returns the smallest then largest number between a & b.
func QuadraticFormula ¶
Computes the quadratic formula between a, b, and c. If it can't be computed then none is returned.
func Sign ¶
Computes the sign of the given number where 0 has a sign of 0, a negative number returns -1 and a positive number returns 1.
func SliceAppendAt ¶
func SliceEnsureSize ¶
func SliceIndexOf ¶
func SliceIndexOf[V comparable](slice []V, value V) int
func SliceRemove ¶
func SliceRemove[E comparable](slice []E, value E) []E
func SliceRemoveAt ¶
func SliceRemoveAtReplace ¶
func SliceResize ¶
func SliceReverse ¶
func SliceReverse[E any](s []E)
func SliceSorted ¶
Types ¶
type Flags ¶
type Flags[T constraints.Integer] struct { // contains filtered or unexported fields }
Utility struct for typed bitwise operations.
type Incrementor ¶
type Incrementor[I constraints.Ordered] struct { // contains filtered or unexported fields }
func NewIncrementor ¶
func NewIncrementor[I constraints.Ordered](initial, increment I) Incrementor[I]
func (*Incrementor[I]) Get ¶
func (i *Incrementor[I]) Get() I
func (Incrementor[I]) Peek ¶
func (i Incrementor[I]) Peek() I
type Match ¶
type Match[T constraints.Integer | constraints.Unsigned] func(value T) bool
A match is a function which is given a single integer and returns whether it matches some criteria.
func MatchAll ¶
func MatchAll[T constraints.Integer | constraints.Unsigned](test T) Match[T]
Creates a match which returns true if all bits in test are on in a given value.
func MatchAlways ¶
func MatchAlways[T constraints.Integer | constraints.Unsigned]() Match[T]
func MatchAnd ¶
func MatchAnd[T constraints.Integer | constraints.Unsigned](ands ...Match[T]) Match[T]
Creates a match which returns true if all given matches return true.
func MatchAny ¶
func MatchAny[T constraints.Integer | constraints.Unsigned](test T) Match[T]
Creates a match which returns true if any bits in test are in a given value.
func MatchEmpty ¶
func MatchEmpty[T constraints.Integer | constraints.Unsigned]() Match[T]
Creates a match which returns true when a given value is zero.
func MatchExact ¶
func MatchExact[T constraints.Integer | constraints.Unsigned](test T) Match[T]
Creates a match which returns true if a given value and test are equal.
func MatchNone ¶
func MatchNone[T constraints.Integer | constraints.Unsigned](test T) Match[T]
Creates a match which returns true if there are no bits in common with a given value.
func MatchNot ¶
func MatchNot[T constraints.Integer | constraints.Unsigned](not Match[T]) Match[T]
Creaes a match which returns the negation of given match.
func MatchOnly ¶
func MatchOnly[T constraints.Integer | constraints.Unsigned](test T) Match[T]
Creates a match which returns true if all bits in a given value are on in test.
func MatchOr ¶
func MatchOr[T constraints.Integer | constraints.Unsigned](ors ...Match[T]) Match[T]
Creates a match which returns true if any given matches return true.