cmp

package
v0.0.0-...-020adb6 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultEq

type DefaultEq[T any] struct {
	EqualImpl func(T, T) bool
}

DefaultEq is Eq with default implementations.

func (*DefaultEq[T]) Equal

func (eq *DefaultEq[T]) Equal(x, y T) bool

type DefaultOrd

type DefaultOrd[T any] struct {
	CompareImpl func(T, T) Ordering
}

DefaultOrd is Ord with default implementations.

func (*DefaultOrd[T]) Compare

func (o *DefaultOrd[T]) Compare(x, y T) Ordering

func (*DefaultOrd[T]) Eq

func (o *DefaultOrd[T]) Eq(x, y T) bool

func (*DefaultOrd[T]) Ge

func (o *DefaultOrd[T]) Ge(x, y T) bool

func (*DefaultOrd[T]) Gt

func (o *DefaultOrd[T]) Gt(x, y T) bool

func (*DefaultOrd[T]) Le

func (o *DefaultOrd[T]) Le(x, y T) bool

func (*DefaultOrd[T]) Lt

func (o *DefaultOrd[T]) Lt(x, y T) bool

func (*DefaultOrd[T]) Ne

func (o *DefaultOrd[T]) Ne(x, y T) bool

type Eq

type Eq[T any] interface {
	// Equal returns true if and only if given two arguments are the same.
	Equal(T, T) bool
}

Eq defines equality of type T.

func DeriveEq

func DeriveEq[T comparable]() Eq[T]

DeriveEq derives Eq using standard `==` operator.

type Ord

type Ord[T any] interface {
	// Compare(x, y) returns:
	//     LT if x < y
	//     EQ if x == y
	//     GT if x > y
	Compare(T, T) Ordering

	// Lt(x, y) means x < y.
	Lt(T, T) bool

	// Le(x, y) means x <= y.
	Le(T, T) bool

	// Gt(x, y) means x > y.
	Gt(T, T) bool

	// Ge(x, y) means x >= y.
	Ge(T, T) bool

	// Eq(x, y) means x == y.
	Eq(T, T) bool

	// Ne(x, y) means x != y.
	Ne(T, T) bool
}

Ord defines order of type T.

func DeriveOrd

func DeriveOrd[T constraints.Ordered]() Ord[T]

DeriveOrd derives Ord using `<`, `<=`, `>`, `>=`, `==`, and `!=`.

type Ordering

type Ordering int
const (
	LT Ordering = iota
	EQ
	GT
)

func (Ordering) GoString

func (o Ordering) GoString() string

Jump to

Keyboard shortcuts

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