This commit is contained in:
aozhiwei 2024-03-27 08:41:33 +08:00
parent 5fe4ba1d1f
commit b934782a38

View File

@ -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() {
if this.NoLoad {
return