func union(a map[string]bool, b map[string]bool) {
	for k := range b {
		a[k] = true
	}
}
union performs a set union of `a` and `b`, storing the results in `a`
package reckon
import "math"
const (
	MaxExampleKeys = 10
	MaxExampleElements = 10
	MaxExampleValues = 10
)
type Statistics struct {
	Mean   float64
	Min    int
	Max    int
	StdDev float64
}
func NewStatistics() *Statistics {
	return &Statistics{
		Mean:   math.NaN(),
		StdDev: math.NaN(),
	}
}
func powerOfTwo(n int) int {
	p := 1
	for p < n {
		p = p * 2
	}
	return p
}
func ComputePowerOfTwoFreq(m map[int]int64) map[int]int64 {
	pf := make(map[int]int64)
	for k, v := range m {
		p := powerOfTwo(k)
		if existing, ok := pf[p]; ok {
			pf[p] = existing + v
		} else {
			pf[p] = v
		}
	}
	return pf
}
func ComputeStatistics(m map[int]int64) Statistics {
	stats := NewStatistics()
	if len(m) == 0 {
		return *stats
	}
	min := math.MaxInt32
	max := math.MinInt32
	accum, count, sd := int64(0), int64(0), float64(0)
	for k, v := range m {
		if k < min {
			min = k
		}
		if k > max {
			max = k
		}
		accum += int64(k) * v
		count += v
	}
	mean := float64(accum) / float64(count)
	for k, v := range m {
		kf, vf := float64(k), float64(v)
		sd += ((kf - mean) * (kf - mean)) * vf
	}
	return Statistics{
		Mean:   mean,
		Min:    min,
		Max:    max,
		StdDev: math.Sqrt(sd / float64(count-1)),
	}
}
func add(set map[string]bool, elem string, maxsize int) {
	if len(set) >= maxsize {
		return
	}
	set[elem] = true
}
type Results struct {
	Name     string
	KeyCount int64
	StringSizes  map[int]int64
	StringKeys   map[string]bool
	StringValues map[string]bool
	SetSizes        map[int]int64
	SetElementSizes map[int]int64
	SetKeys         map[string]bool
	SetElements     map[string]bool
	SortedSetSizes        map[int]int64
	SortedSetElementSizes map[int]int64
	SortedSetKeys         map[string]bool
	SortedSetElements     map[string]bool
	HashSizes        map[int]int64
	HashElementSizes map[int]int64
	HashValueSizes   map[int]int64
	HashKeys         map[string]bool
	HashElements     map[string]bool
	HashValues       map[string]bool
	ListSizes        map[int]int64
	ListElementSizes map[int]int64
	ListKeys         map[string]bool
	ListElements     map[string]bool
}
func NewResults() *Results {
	return &Results{
		StringSizes:  make(map[int]int64),
		StringKeys:   make(map[string]bool),
		StringValues: make(map[string]bool),
		SetSizes:        make(map[int]int64),
		SetElementSizes: make(map[int]int64),
		SetKeys:         make(map[string]bool),
		SetElements:     make(map[string]bool),
		SortedSetSizes:        make(map[int]int64),
		SortedSetElementSizes: make(map[int]int64),
		SortedSetKeys:         make(map[string]bool),
		SortedSetElements:     make(map[string]bool),
		HashSizes:        make(map[int]int64),
		HashElementSizes: make(map[int]int64),
		HashValueSizes:   make(map[int]int64),
		HashKeys:         make(map[string]bool),
		HashElements:     make(map[string]bool),
		HashValues:       make(map[string]bool),
		ListSizes:        make(map[int]int64),
		ListElementSizes: make(map[int]int64),
		ListKeys:         make(map[string]bool),
		ListElements:     make(map[string]bool),
	}
}
func merge(a map[int]int64, b map[int]int64) {
	for k, v := range b {
		a[k] += v
	}
}