1
This commit is contained in:
parent
5fe4ba1d1f
commit
b934782a38
13
metatable.go
13
metatable.go
@ -102,6 +102,19 @@ func (this *IdMetaTable[T]) GetById(id int64) *T {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *IdMetaTable[T]) RandElementExclude(cb func(*T) bool) *T {
|
||||||
|
if len(this.rawList) > 0 {
|
||||||
|
tryCount := 1
|
||||||
|
for tryCount < 1000 {
|
||||||
|
meta := this.rawList[rand.Intn(len(this.rawList))]
|
||||||
|
if cb(meta) {
|
||||||
|
return meta
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (this *RawMetaTable[T]) Load() {
|
func (this *RawMetaTable[T]) Load() {
|
||||||
if this.NoLoad {
|
if this.NoLoad {
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user