package character

type Histogram struct {
	counts [256]uint16
}

func StringHistogram(text string) *Histogram {
	histogram := &Histogram{}
	for i := 0; i < len(text); i++ {
		histogram.Add(Char(text[i]))
	}
	return histogram
}

func (h *Histogram) Add(char Char) {
	h.counts[char]++
}

func (h *Histogram) Count(char Char) int {
	return int(h.counts[char])
}
