constraints

package
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 0 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asc added in v0.3.4

func Asc[T Ordered](x, y T) int

Asc returns

-1 if x is less than y,
 0 if x equals y,
+1 if x is greater than y.

For floating-point types, a NaN is considered less than any non-NaN, a NaN is considered equal to a NaN, and -0.0 is equal to 0.0.

func Dec added in v0.3.4

func Dec[T Ordered](x, y T) int

Dec returns

-1 if x is greater than y,
 0 if x equals y,
+1 if x is less than y.

For floating-point types, a NaN is considered less than any non-NaN, a NaN is considered equal to a NaN, and -0.0 is equal to 0.0.

func Equal added in v0.3.4

func Equal[T comparable](x, y T) bool

func Greater added in v0.3.4

func Greater[T Ordered](x, y T) bool

func Less added in v0.3.4

func Less[T Ordered](x, y T) bool

Less reports whether x is less than y. For floating-point types, a NaN is considered less than any non-NaN, and -0.0 is not less than (is equal to) 0.0.

Types

type Complex

type Complex interface {
	~complex64 | ~complex128
}

Complex is a constraint that permits any complex numeric type.

type Field

type Field interface {
	Float | Complex
}

Field is a constraint that permits any number field type.

type Float

type Float interface {
	~float32 | ~float64
}

Float is a constraint that permits any floating-point type.

type Integer

type Integer interface {
	Signed | Unsigned
}

Integer is a constraint that permits any integer type.

type Number

type Number interface {
	Real | Complex
}

Number is a constraint that permits any number type.

type Ordered

type Ordered interface {
	Integer | Float | ~string
}

Ordered is a constraint that permits any ordered type: any type that supports the operators < <= >= >.

type Real

type Real interface {
	Integer | Float
}

Real is a constraint that permits any real number type.

type Signed

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

Signed is a constraint that permits any signed integer type.

type SignedNumber

type SignedNumber interface {
	SignedReal | Complex
}

SignedNumber is a constraint that permits any signed integer, floating-point and complex-numeric type.

type SignedReal

type SignedReal interface {
	Signed | Float
}

SignedReal is a constraint that permits any signed integer and floating-point type.

type Unsigned

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Unsigned is a constraint that permits any unsigned integer type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL