Documentation ¶
Overview ¶
Package cmp provides comparators for sorting linked lists.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LessThanCustom ¶
LessThanCustom converts types that implement OrderableUser interface.
func LessThanNative ¶
func LessThanNative[T OrderableNative](a, b T) bool
LessThanNative provides a wrapper around the < operator for types that support it, and can be used for sorting lists of compatible types.
func LessThanTime ¶
LessThanTime compares time using the time.Time.Before() method.
Types ¶
type LessThan ¶
LessThan describes a less than operation, typically provided by one of the following operations.
func LessThanConverter ¶
func LessThanConverter[T any, S OrderableNative](converter func(T) S) LessThan[T]
LessThanConverter provides a function to convert a non-orderable type to an orderable type. Use this for
type Orderable ¶
OrderableUser allows users to define a method on their types which implement a method to provide a LessThan operation.
type OrderableNative ¶
type OrderableNative interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64 | ~string }
OrderableNative describes all native types which (currently) support the < operator. To order custom types, use the OrderableUser interface.
In the future an equivalent oderable type specification is likely to enter the standard library, which will supercede this type.