EncodeMsg encodes the message to the writer.
(writer *msgp.Writer)
| 3553 | |
| 3554 | // EncodeMsg encodes the message to the writer. |
| 3555 | func (s Float64Sorted) EncodeMsg(writer *msgp.Writer) error { |
| 3556 | if s == nil { |
| 3557 | return writer.WriteNil() |
| 3558 | } |
| 3559 | err := writer.WriteArrayHeader(uint32(len(s))) |
| 3560 | if err != nil { |
| 3561 | return err |
| 3562 | } |
| 3563 | keys := make([]float64, 0, len(s)) |
| 3564 | for k := range s { |
| 3565 | keys = append(keys, k) |
| 3566 | } |
| 3567 | slices.SortFunc(keys, func(a, b float64) int { |
| 3568 | if a < b { |
| 3569 | return -1 |
| 3570 | } |
| 3571 | return 1 |
| 3572 | }) |
| 3573 | |
| 3574 | for _, k := range keys { |
| 3575 | err = writer.WriteFloat(k) |
| 3576 | if err != nil { |
| 3577 | return err |
| 3578 | } |
| 3579 | } |
| 3580 | return nil |
| 3581 | } |
| 3582 | |
| 3583 | // MarshalMsg encodes the message to the bytes. |
| 3584 | func (s Float64Sorted) MarshalMsg(bytes []byte) ([]byte, error) { |