func (c *RollingCounter) Inc(v int) {
	c.cleanup()
	c.incBucketValue(v)
}
Inc increment counter
package memmetrics
import (
	"fmt"
	"time"
	"github.com/mailgun/timetools"
)
type rcOptSetter func(*RollingCounter) error
func CounterClock(c timetools.TimeProvider) rcOptSetter {
	return func(r *RollingCounter) error {
		r.clock = c
		return nil
	}
}
type RollingCounter struct {
	clock          timetools.TimeProvider
	resolution     time.Duration
	values         []int
	countedBuckets int  
	lastBucket     int  
	lastUpdated    time.Time
}
func NewCounter(buckets int, resolution time.Duration, options ...rcOptSetter) (*RollingCounter, error) {
	if buckets <= 0 {
		return nil, fmt.Errorf("Buckets should be >= 0")
	}
	if resolution < time.Second {
		return nil, fmt.Errorf("Resolution should be larger than a second")
	}
	rc := &RollingCounter{
		lastBucket: -1,
		resolution: resolution,
		values: make([]int, buckets),
	}
	for _, o := range options {
		if err := o(rc); err != nil {
			return nil, err
		}
	}
	if rc.clock == nil {
		rc.clock = &timetools.RealTime{}
	}
	return rc, nil
}
func (c *RollingCounter) Append(o *RollingCounter) error {
	c.Inc(int(o.Count()))
	return nil
}
func (c *RollingCounter) Clone() *RollingCounter {
	c.cleanup()
	other := &RollingCounter{
		resolution:  c.resolution,
		values:      make([]int, len(c.values)),
		clock:       c.clock,
		lastBucket:  c.lastBucket,
		lastUpdated: c.lastUpdated,
	}
	copy(other.values, c.values)
	return other
}
func (c *RollingCounter) Reset() {
	c.lastBucket = -1
	c.countedBuckets = 0
	c.lastUpdated = time.Time{}
	for i := range c.values {
		c.values[i] = 0
	}
}
func (c *RollingCounter) CountedBuckets() int {
	return c.countedBuckets
}
func (c *RollingCounter) Count() int64 {
	c.cleanup()
	return c.sum()
}
func (c *RollingCounter) Resolution() time.Duration {
	return c.resolution
}
func (c *RollingCounter) Buckets() int {
	return len(c.values)
}
func (c *RollingCounter) WindowSize() time.Duration {
	return time.Duration(len(c.values)) * c.resolution
}