Documentation ¶
Index ¶
- func Compare[T constraints.Ordered](x, y T) int
- func CompareByKey[K constraints.Ordered, T CompareKey[K]](a T, b T) int
- func CompareNumber[T constraintsi.Number](a T, b T) int
- func Equal[T comparable](a T, b T) bool
- func EqualByKey[K constraints.Ordered, T CompareKey[K]](a T, b T) bool
- func FloatFlip[T constraints.Float](i T) T
- func Greater[T constraints.Ordered](a T, b T) bool
- func GreaterByKey[K constraints.Ordered, T CompareKey[K]](a T, b T) bool
- func Less[T constraints.Ordered](a T, b T) bool
- func LessByKey[K constraints.Ordered, T CompareKey[K]](a T, b T) bool
- func SignedFlip[T constraints.Signed](i T) T
- func UnSignedFlip[T constraints.Unsigned](i T) T
- type Comparable
- type ComparableKey
- type CompareFunc
- type CompareKey
- type CompareLess
- type CompareNumKey
- type EqualKey
- type GTValue
- type IsEqual
- type LTValue
- type LessFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
func Compare[T constraints.Ordered](x, y T) int
func CompareByKey ¶
func CompareByKey[K constraints.Ordered, T CompareKey[K]](a T, b T) int
func CompareNumber ¶
func CompareNumber[T constraintsi.Number](a T, b T) int
func Equal ¶
func Equal[T comparable](a T, b T) bool
func EqualByKey ¶
func EqualByKey[K constraints.Ordered, T CompareKey[K]](a T, b T) bool
func FloatFlip ¶
func FloatFlip[T constraints.Float](i T) T
func Greater ¶
func Greater[T constraints.Ordered](a T, b T) bool
func GreaterByKey ¶
func GreaterByKey[K constraints.Ordered, T CompareKey[K]](a T, b T) bool
func Less ¶
func Less[T constraints.Ordered](a T, b T) bool
func LessByKey ¶
func LessByKey[K constraints.Ordered, T CompareKey[K]](a T, b T) bool
func SignedFlip ¶
func SignedFlip[T constraints.Signed](i T) T
func UnSignedFlip ¶
func UnSignedFlip[T constraints.Unsigned](i T) T
Types ¶
type Comparable ¶
包含了CompareLess和IsEqual,尽量统一使用Comparable
type ComparableKey ¶
type ComparableKey[T Comparable[T]] interface { CompareKey() T }
type CompareFunc ¶
type CompareKey ¶
type CompareKey[T constraints.Ordered] interface { CompareKey() T }
下面不推荐使用 合理使用,如int, 正序 return v,倒序return -v,并适当考虑边界值问题
type CompareLess ¶
type EqualKey ¶
type EqualKey[T comparable] interface { EqualKey() T }
type GTValue ¶
type GTValue[T constraints.Ordered] struct { Value T }
type LTValue ¶
type LTValue[T constraints.Ordered] struct { Value T }
Click to show internal directories.
Click to hide internal directories.