Files
aoi/aoi.go
knight0zh d18f22e8f8 优化
2022-08-17 17:08:08 +08:00

29 lines
475 B
Go

package aoi
import "sync"
type AOI interface {
Add(x, y float64, name string) // 添加实体
Delete(x, y float64, name string) // 移除实体
Search(x, y float64) (result []string) // 范围查询
}
type Entity struct {
X, Y float64
Key string
}
var (
resultPool sync.Pool
entityPool sync.Pool
)
func init() {
resultPool.New = func() interface{} {
return make([]string, 0, 500)
}
entityPool.New = func() interface{} {
return &Entity{}
}
}