bin.go 584 B

12345678910111213141516171819202122232425262728
  1. // Unless explicitly stated otherwise all files in this repository are licensed
  2. // under the Apache License 2.0.
  3. // This product includes software developed at Datadog (https://www.datadoghq.com/).
  4. // Copyright 2021 Datadog, Inc.
  5. package store
  6. import "errors"
  7. type Bin struct {
  8. index int
  9. count float64
  10. }
  11. func NewBin(index int, count float64) (*Bin, error) {
  12. if count < 0 {
  13. return nil, errors.New("The count cannot be negative")
  14. }
  15. return &Bin{index: index, count: count}, nil
  16. }
  17. func (b Bin) Index() int {
  18. return b.index
  19. }
  20. func (b Bin) Count() float64 {
  21. return b.count
  22. }