Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Func ¶
Func returns a function able to compare 2 reflect.Value values.
The sorting rules are listed in Values documentation.
Cyclic references are correctly handled.
func MapEach ¶
MapEach calls fn for each key/value pair of map m using the order of keys. If fn returns false, it will not be called again. MapEach returns false if fn returned false.
func Values ¶
Values is used to allow the sorting of a []reflect.Value slice. It is used with the standard sort package:
vals := []reflect.Value{a, b, c, d}
sort.Sort(Values(vals))
// vals contents now sorted
Replace sort.Sort by sort.Stable for a stable sort. See sort documentation.
Sorting rules are as follows:
- invalid value is always lower
- nil is always lower
- different types are sorted by their name
- if method TYPE.Compare(TYPE) int exits, calls it
- false is lesser than true
- float and int numbers are sorted by their value, NaN is always lower
- complex numbers are sorted by their real, then by their imaginary parts
- strings are sorted by their value
- map: shorter length is lesser, then sorted by address
- functions, channels and unsafe pointer are sorted by their address
- struct: comparison is spread to each field
- pointer: comparison is spread to the pointed value
- arrays: comparison is spread to each item
- slice: comparison is spread to each item, then shorter length is lesser
- interface: comparison is spread to the value
Cyclic references are correctly handled.
See also Func.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.