Documentation
¶
Overview ¶
Package compare contains support functions for comparison of values.
Comparison Functions ¶
For the purposes of this package, a comparison function takes two values A and B of a type and reports their relative order, returning:
-1 if A precedes B, 0 if A and B are equivalent, +1 if A follows B
Comparison functions are expected to implement a strict weak ordering. Unless otherwise noted, any negative value is accepted in place of -1, and any positive value in place of 1.
Less Functions ¶
For the purposes of this package, a less function takes two values A and B of a type and reports whether A precedes B in relative order.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶ added in v0.21.4
Bool is a comparison function for bool values that orders false before true.
func FromLessFunc ¶ added in v0.8.2
FromLessFunc converts a less function, which reports whether its first argument precedes its second in an ordering relation, into a comparison function on that same relation.
func Reversed ¶ added in v0.13.4
Reversed returns a comparison function that orders its elements in the reverse of the ordering expressed by c.
func Time ¶ added in v0.13.4
Time is a comparison function for time.Time values that orders earlier times before later ones.
func ToLessFunc ¶ added in v0.8.3
ToLessFunc converts a comparison function into a less function on the same relation.
Types ¶
This section is empty.