package two import "sync" type antiNodeCache struct { mu sync.RWMutex data map[coords]struct{} } func newAntiNodeCache() antiNodeCache { return antiNodeCache{ data: make(map[coords]struct{}), } } func (c *antiNodeCache) len() int { return len(c.data) } func (c *antiNodeCache) contains(coords coords) bool { c.mu.RLock() defer c.mu.RUnlock() _, ok := c.data[coords] return ok } func (c *antiNodeCache) insert(coords coords) { c.mu.Lock() defer c.mu.Unlock() c.data[coords] = struct{}{} }