// 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} }
// 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) }