예제 #1
0
func Insert(model Model) Model {
	counters := model.counters[:] // Copy counters
	return Model{
		counters: append(counters, Counter{id: model.nextID, counter: c.Model(0)}),
		nextID:   model.nextID + 1,
	}
}
예제 #2
0
func Init(values ...int) Model {
	m := Model{nextID: ID(len(values))}
	for id, value := range values {
		m.counters = append(m.counters, Counter{id: ID(id), counter: c.Model(value)})
	}
	return m
}