1 Star 0 Fork 0

wuzpdev/goworld

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
entityid_set.go 782 Bytes
一键复制 编辑 原始数据 按行查看 历史
seis 提交于 2018-06-11 23:18 +08:00 . SetGameID
package common
// EntityIDSet is the data structure for a set of entity IDs
type EntityIDSet map[EntityID]struct{}
// Add adds an entity ID to EntityIDSet
func (es EntityIDSet) Add(id EntityID) {
es[id] = struct{}{}
}
// Del removes an entity ID from EntityIDSet
func (es EntityIDSet) Del(id EntityID) {
delete(es, id)
}
// Contains checks if entity ID is in EntityIDSet
func (es EntityIDSet) Contains(id EntityID) bool {
_, ok := es[id]
return ok
}
// ToList convert EntityIDSet to a slice of entity IDs
func (es EntityIDSet) ToList() []EntityID {
list := make([]EntityID, 0, len(es))
for eid := range es {
list = append(list, eid)
}
return list
}
func (es EntityIDSet) ForEach(cb func(eid EntityID) bool) {
for eid := range es {
if !cb(eid) {
break
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzpdev/goworld.git
git@gitee.com:wuzpdev/goworld.git
wuzpdev
goworld
goworld
v0.1.6

搜索帮助