mirror of
https://github.com/moby/moby.git
synced 2026-08-03 14:41:03 +00:00
These are no longer needed as these are now part of a module. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
17 lines
322 B
Go
17 lines
322 B
Go
package countmap
|
|
|
|
// Map is a map of counters.
|
|
type Map[T comparable] map[T]int
|
|
|
|
// Add adds delta to the counter for v and returns the new value.
|
|
//
|
|
// If the new value is 0, the entry is removed from the map.
|
|
func (m Map[T]) Add(v T, delta int) int {
|
|
m[v] += delta
|
|
c := m[v]
|
|
if c == 0 {
|
|
delete(m, v)
|
|
}
|
|
return c
|
|
}
|