Documentation ¶
Overview ¶
Package utils has various utils used by algo and dstruct.
Index ¶
- func Add[T Number](a, b T) T
- func And(a, b bool) bool
- func Append[T any](acc []T, t T) []T
- func Div[T Number](a, b T) T
- func Eq[T Number](a, b T) bool
- func Ge[T Number](a, b T) bool
- func Gt[T Number](a, b T) bool
- func Identity[T any](a T) T
- func Le[T Number](a, b T) bool
- func Lt[T Number](a, b T) bool
- func Max[T Number](a, b T) T
- func Min[T Number](a, b T) T
- func Mul[T Number](a, b T) T
- func Or(a, b bool) bool
- func Sub[T Number](a, b T) T
- type Comparator
- type Number
- type Predicate
- type Signed
- type SignedInt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Comparator ¶
Comparator is a function that returns a boolean based on two inputs. It should be stateless, and allow for a total ordering of elements in T such that a precedes b if, and only if, Comparator(a,b)==true. Functions that require a comparator input will assume as much.
func Equal ¶
func Equal[T any](comp Comparator[T]) Comparator[T]
Equal takes returns an equality check. Two items are considered equal if their position is equivalent according to the ordering defined by the comparator.
type Number ¶
type Number interface { constraints.Integer | constraints.Float }
Number constrains numeric values.
type Predicate ¶
Predicate is a function that returns a boolean based on a single input. Furthermore, it should be stateless. Functions that require a predicate input will assume as much.
type Signed ¶
type Signed interface { constraints.Signed | constraints.Float }
Signed constrains to Numbers where negative values can be represented.
type SignedInt ¶
type SignedInt interface { constraints.Signed }
SignedInt to integers where negative values can be represented.