38 lines
612 B
Go
38 lines
612 B
Go
package mt
|
|
|
|
import (
|
|
"q5"
|
|
"f5"
|
|
"mtb"
|
|
"strings"
|
|
)
|
|
|
|
type Item struct {
|
|
mtb.Item
|
|
lowerName string
|
|
}
|
|
|
|
type ItemTable struct {
|
|
f5.IdMetaTable[Item]
|
|
itemIdHash *q5.ConcurrentMap[int64, *Item]
|
|
}
|
|
|
|
func (this *Item) Init1() {
|
|
this.lowerName = strings.ToLower(this.GetName())
|
|
}
|
|
|
|
func (this *ItemTable) Load() {
|
|
this.itemIdHash = new(q5.ConcurrentMap[int64, *Item])
|
|
}
|
|
|
|
func (this *ItemTable) Search(name string, itemIds map[int32]int32) {
|
|
name = strings.ToLower(name)
|
|
this.Traverse(
|
|
func (ele *Item) bool {
|
|
if strings.Contains(ele.lowerName, name) {
|
|
itemIds[ele.GetId()] = 1
|
|
}
|
|
return true
|
|
})
|
|
}
|