mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 06:10:47 +00:00
22 lines
323 B
Go
22 lines
323 B
Go
package two
|
|
|
|
import "sync"
|
|
|
|
type sequenceCache struct {
|
|
mu sync.RWMutex
|
|
data map[sequence]int
|
|
}
|
|
|
|
func newSequenceCache() sequenceCache {
|
|
return sequenceCache{
|
|
data: make(map[sequence]int),
|
|
}
|
|
}
|
|
|
|
func (sc *sequenceCache) upsert(seq sequence, value int) {
|
|
sc.mu.Lock()
|
|
defer sc.mu.Unlock()
|
|
|
|
sc.data[seq] += value
|
|
}
|