counter

package
v4.2.26+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter interface {
	// Add increments the value for key by delta.
	Add(key interface{}, delta int)

	// Values returns the counted values.
	Values() M

	// Diff returns the difference between the counted values and m. A return
	// value of nil indicates no difference.
	Diff(m M) []Difference
}

Counter adds integers for different keys.

func New

func New() Counter

New returns a counter that is safe for concurrent use by multiple goroutines.

type Difference

type Difference struct {
	Key  interface{}
	Got  int
	Want int
}

Difference represents a mismatch of an actual value and an expected value for a key in a counter.

func (Difference) String

func (d Difference) String() string

type M

type M map[interface{}]int

M is a map with a counted values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL