mirror of
https://github.com/knight0zh/aoi.git
synced 2026-02-03 23:55:09 +08:00
29 lines
475 B
Go
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{}
|
|
}
|
|
}
|