Exemplo n.º 1
0
// Freeze a counter, using a previously-generated keyset and
// index.
func FreezeWithKeySet(c *counter.Counter, ks *KeySet) *Counter {
	values := make([]float64, len(ks.Keys))

	for s, idx := range ks.Positions {
		values[idx] = c.Get(s)
	}

	return &Counter{ks, values}
}
Exemplo n.º 2
0
// Convert a counter.Counter into a frozen counter, returning the new
// frozen counter and the index required to convert it back.
func Freeze(c *counter.Counter) *Counter {
	ks := NewKeySet(c.Keys(), c.Base)

	return FreezeWithKeySet(c, ks)
}