Documentation ¶
Index ¶
- func Max(R TotalOrder, S ...object.Element) (object.Element, error)
- func MaxAndIndex(R TotalOrder, S []object.Element) (object.Element, int, error)
- func MaxOfPair(R TotalOrder, x object.Element, y object.Element) (object.Element, error)
- func Min(R TotalOrder, S ...object.Element) (object.Element, error)
- func MinAndIndex(R TotalOrder, S []object.Element) (object.Element, int, error)
- func MinOfPair(R TotalOrder, x object.Element, y object.Element) (object.Element, error)
- func Sort(R TotalOrder, S []object.Element) ([]object.Element, error)
- func SortWithFunc(less LessFunc, S []object.Element) ([]object.Element, error)
- type CmpFunc
- type Cmper
- type LessFunc
- type TotalOrder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Max ¶
Max returns the maximum element in the slice S. The maximum is calculated with respect to the total order R. If S is empty then an error is returned. If R satisfies the interface:
type Maxer interface { Max(S ...object.Element) (object.Element, error) // Max returns the maximum element in the slice S. If S is empty then an error is returned. }
then R's Max method will be called.
func MaxAndIndex ¶
MaxAndIndex returns the maximum element in the slice S, along with the index of the first occurrence of that element in S. The maximum is calculated with respect to the total order R. If S is empty then an error is returned. If R satisfies the interface:
type MaxAndIndexer interface { MaxAndIndex(S []object.Element) (object.Element, int, error) // MaxAndIndex returns the maximum element in the slice S, along with the index of the first occurrence of that element in S. If S is empty then an error is returned. }
then R's MaxAndIndex method will be called.
func MaxOfPair ¶
MaxOfPair returns the maximum element of x and y. The maximum is calculated with respect to the total order R.
func Min ¶
Min returns the minimum element in the slice S. The minimum is calculated with respect to the total order R. If S is empty then an error is returned. If R satisfies the interface:
type Miner interface { Min(S ...object.Element) (object.Element, error) // Min returns the minimum element in the slice S. If S is empty then an error is returned. }
then R's Min method will be called.
func MinAndIndex ¶
MinAndIndex returns the minimum element in the slice S, along with the index of the first occurrence of that element in S. The minimum is calculated with respect to the total order R. If S is empty then an error is returned. If R satisfies the interface:
type MinAndIndexer interface { MinAndIndex(S []object.Element) (object.Element, int, error) // MinAndIndex returns the minimum element in the slice S, along with the index of the first occurrence of that element in S. If S is empty then an error is returned. }
then R's MinAndIndex method will be called.
func MinOfPair ¶
MinOfPair returns the minimum element of x and y. The minimum is calculated with respect to the total order R.
func Sort ¶
Sort non-destructively sorts the given slice of elements using the given TotalOrder. The sorted slice is returned. If R satisfies the interface:
type Sorter interface { Sort(S []object.Element) ([]object.Element, error) // Sort non-destructively sorts the given slice of elements. The sorted slice is returned. }
then R's Sort method will be called.
Types ¶
type Cmper ¶
type Cmper interface {
Cmp(x object.Element, y object.Element) (int, error) // Cmp returns -1 if x < y, 0 if x == y, and +1 if x > y.
}
Cmper is the interface satisfied by the Cmp method.
type LessFunc ¶
LessFunc can be used to sort a slice of elements. It should return true iff x < y. The function must be safe to be called concurrently by multiple go routines.
type TotalOrder ¶
type TotalOrder interface { object.Containser Cmper }
TotalOrder is the interface satisfied by a total order.