cmp

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare[T constraints.Ordered](x, y T) int

func CompareByKey added in v1.7.0

func CompareByKey[K constraints.Ordered, T SortKey[K]](a T, b T) int

func CompareNumber added in v1.7.0

func CompareNumber[T constraintsi.Number](a T, b T) int

func Equal

func Equal[T comparable](a T, b T) bool

func EqualByKey added in v1.7.0

func EqualByKey[K constraints.Ordered, T SortKey[K]](a T, b T) bool

func Greater

func Greater[T constraints.Ordered](a T, b T) bool

func GreaterByKey added in v1.7.0

func GreaterByKey[K constraints.Ordered, T SortKey[K]](a T, b T) bool

func Less

func Less[T constraints.Ordered](a T, b T) bool

func LessByKey added in v1.7.0

func LessByKey[K constraints.Ordered, T SortKey[K]](a T, b T) bool

Types

type Comparable added in v1.7.0

type Comparable[T any] interface {
	Compare(T) int
}

type CompareFunc

type CompareFunc[T any] func(T, T) int

type CompareKey

type CompareKey[T constraintsi.Number] interface {
	CompareKey() T
}

type EqualKey added in v1.7.0

type EqualKey[T comparable] interface {
	EqualKey() T
}

type GTValue

type GTValue[T constraints.Ordered] struct {
	Value T
}

func (GTValue[T]) Compare

func (a GTValue[T]) Compare(b GTValue[T]) bool

type IsEqual added in v1.7.0

type IsEqual[T any] interface {
	Equal(T) bool
}

type LTValue

type LTValue[T constraints.Ordered] struct {
	Value T
}

func (LTValue[T]) Compare

func (a LTValue[T]) Compare(b GTValue[T]) bool

type Sort

type Sort[T any] interface {
	Less(T) bool
}

type SortFunc

type SortFunc[T any] func(T, T) bool

type SortKey added in v1.7.0

type SortKey[T constraints.Ordered] interface {
	SortKey() T
}

comparable 只能比较是否相等,不能比较大小

Jump to

Keyboard shortcuts

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