Example #1
0
func distinct(list vector.StringVector) [][2]string {
	if len(list) == 0 {
		return nil
	}
	var keys vector.StringVector
	var vals vector.IntVector
	for _, l := range list {
		index := search(keys, l)
		if index == -1 {
			keys.Push(l)
			vals.Push(1)
		} else {
			vals.Set(index, vals.At(index)+1)
		}
	}
	m := make([][2]string, len(keys))
	for i, k := range keys {
		m[i][0] = k
		m[i][1] = fmt.Sprint(vals.At(i))
	}
	return m
}