qbtrade/pkg/fixedpoint/slice.go
2024-06-27 22:42:38 +08:00

25 lines
798 B
Go

package fixedpoint
type Slice []Value
func (s Slice) Reduce(reducer Reducer, a ...Value) Value {
return Reduce(s, reducer, a...)
}
// Defaults to ascending sort
func (s Slice) Len() int { return len(s) }
func (s Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s Slice) Less(i, j int) bool { return s[i].Compare(s[j]) < 0 }
type Ascending []Value
func (s Ascending) Len() int { return len(s) }
func (s Ascending) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s Ascending) Less(i, j int) bool { return s[i].Compare(s[j]) < 0 }
type Descending []Value
func (s Descending) Len() int { return len(s) }
func (s Descending) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s Descending) Less(i, j int) bool { return s[i].Compare(s[j]) > 0 }