(key T, values []float64)
| 533 | } |
| 534 | |
| 535 | func (t *topN[T]) add(key T, values []float64) { |
| 536 | sum := 0.0 |
| 537 | for _, v := range values { |
| 538 | sum += v |
| 539 | } |
| 540 | t.entries = append(t.entries, struct { |
| 541 | key T |
| 542 | total float64 |
| 543 | }{key, sum}) |
| 544 | } |
| 545 | |
| 546 | // get the top N values. Given as a callback to avoid allocating. |
| 547 | // bool result indicates if there were more than N values |