This commit is contained in:
knight0zh
2022-08-17 17:08:08 +08:00
parent 59e6f5d6c1
commit d18f22e8f8
7 changed files with 199 additions and 177 deletions

24
aoi.go
View File

@@ -1,12 +1,28 @@
package aoi
import "sync"
type AOI interface {
Add(entity *Entity) // 添加实体
Delete(entity *Entity) // 移除实体
Search(entity *Entity) (result []*Entity) // 范围查询
Add(x, y float64, name string) // 添加实体
Delete(x, y float64, name string) // 移除实体
Search(x, y float64) (result []string) // 范围查询
}
type Entity struct {
X, Y float64
Name string
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{}
}
}