constraints

package
v0.0.0-...-24ca9bf Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT, MIT Imports: 0 Imported by: 0

Documentation

Overview

Package constraints defines a set of useful constraints to be used with type parameters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basic

type Basic[O Ordered] struct{ Val O }

Basic is a parameterized type that abstracts over the entire class of Ordered types (the set of Go built-in types which respond to < <= >= > == != operators) and exposes this behavior via methods so that they fall under the Orderer constraint.

func (Basic[O]) EQ

func (self Basic[O]) EQ(other Basic[O]) bool

EQ implements Orderer[Basic[O]] for Basic[O]. Returns true if the value of the caller is equal to that of the parameter; otherwise returns false.

func (Basic[O]) GE

func (self Basic[O]) GE(other Basic[O]) bool

GE implements Orderer[Basic[O]] for Basic[O]. Returns true if the value of the caller is greater than or equal to that of the parameter; otherwise returns false.

func (Basic[O]) GT

func (self Basic[O]) GT(other Basic[O]) bool

GT implements Orderer[Basic[O]] for Basic[O]. Returns true if the value of the caller is greater than that of the parameter; otherwise returns false.

func (Basic[O]) LE

func (self Basic[O]) LE(other Basic[O]) bool

LE implements Orderer[Basic[O]] for Basic[O]. Returns true if the value of the caller is less than or equal to that of the parameter; otherwise returns false.

func (Basic[O]) LT

func (self Basic[O]) LT(other Basic[O]) bool

LT implements Orderer[Basic[O]] for Basic[O]. Returns true if the value of the caller is less than that of the parameter; otherwise returns false.

func (Basic[O]) NE

func (self Basic[O]) NE(other Basic[O]) bool

NE implements Orderer[Basic[O]] for Basic[O]. Returns true if the value of the caller is not equal to that of the parameter; otherwise returns false.

type Comparable

type Comparable interface{ comparable }

Comparable is an interface that is implemented by all comparable types (booleans, numbers, strings, pointers, channels, arrays of comparable types, structs whose fields are all comparable types). The Comparable interface may only be used as a type parameter constraint, not as the type of a variable. If future releases of Go add new comparable types, this constraint will be modified to include them.

type Comparabler

type Comparabler[O any] interface {
	EQ(other O) bool
	NE(other O) bool
}

type Complex

type Complex interface {
	~complex64 | ~complex128
}

Complex is a constraint that permits any complex numeric . If future releases of Go add new predeclared complex numeric types, this constraint will be modified to include them.

type Float

type Float interface {
	~float32 | ~float64
}

Float is a constraint that permits any floating-point type. If future releases of Go add new predeclared floating-point types, this constraint will be modified to include them.

type Integer

type Integer interface {
	Signed | Unsigned
}

Integer is a constraint that permits any integer type. If future releases of Go add new predeclared integer types, this constraint will be modified to include them.

type Integer64

type Integer64 interface {
	Signed64 | Unsigned64
}

Integer is a constraint that permits any integer type 64 bits in size. If future releases of Go add new predeclared integer types, this constraint will be modified to include them.

type IntegerNo8Bit

type IntegerNo8Bit interface {
	SignedNo8Bit | UnsignedNo8Bit
}

IntegerNo8Bit is a constraint that permits any integer type larger than 8 bits. If future releases of Go add new predeclared integer types, this constraint will be modified to include them.

type Number

type Number interface {
	Integer | Float | Complex
}

Number is a constraint that permits any real or complex number type. If future releases of Go add new predeclared real or complex types, this constraint will be modified to include them.

type Ordered

type Ordered interface {
	Integer | Float | ~string
}

Ordered is a constraint that permits any ordered type: any type that supports the operators < <= >= >, as well as == and !=. If future releases of Go add new ordered types, this constraint will be modified to include them.

type Orderer

type Orderer[O any] interface {
	Comparabler[O]
	LT(other O) bool
	GT(other O) bool
	LE(other O) bool
	GE(other O) bool
}

type Real

type Real interface {
	Integer | Float
}

Real is a constraint that permits any real number type. If future releases of Go add new predeclared integer or floating-point types, this constraint will be modified to include them.

type Real64

type Real64 interface {
	Integer64 | ~float64
}

Real64 is a constraint that permits any real number type 64 bits in size. If future releases of Go add new predeclared integer or floating-point types, this constraint will be modified to include them.

type Signed

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

Signed is a constraint that permits any signed integer type. If future releases of Go add new predeclared signed integer types, this constraint will be modified to include them.

type Signed64

type Signed64 interface {
	~int | ~int64
}

SignedNo8Bit is a constraint that permits any signed integer 64 bits in size. If future releases of Go add new predeclared signed integer types, this constraint will be modified to include them.

type SignedNo8Bit

type SignedNo8Bit interface {
	~int | ~int16 | ~int32 | ~int64
}

SignedNo8Bit is a constraint that permits any signed integer type larger than 8 bits. If future releases of Go add new predeclared signed integer types, this constraint will be modified to include them.

type Sortable

type Sortable interface {
	Ordered | UserSorter[Sorter]
}

Sortable defines a sortable constraint that allows user defined sortable types.

type Sorter

type Sorter interface {
	Len() int
	Less(i, j int)
	Swap(i, j int)
}

Sorter is the interface for sorting from the standard library sort package.

type Text

type Text interface {
	~string | []byte
}

Text defines a text constraint that permits types that are often used to represent text streams.

type Unsigned

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

Unsigned 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 Unsigned64

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

Unsigned64 is a constraint that permits any unsigned integer 64 bits in size. If future releases of Go add new predeclared unsigned integer types, this constraint will be modified to include them.

type UnsignedNo8Bit

type UnsignedNo8Bit interface {
	~uint | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

UnsignedNo8Bit is a constraint that permits any unsigned integer type larger than 8 bits. If future releases of Go add new predeclared unsigned integer types, this constraint will be modified to include them.

type UserSorter

type UserSorter[T Sorter] interface{ *T }

Jump to

Keyboard shortcuts

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