v0.0.575 DelayedCombiningInvoker
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m31s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m31s
This commit is contained in:
@@ -119,6 +119,25 @@ func (s *SyncMap[TKey, TData]) Delete(key TKey) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
func (s *SyncMap[TKey, TData]) DeleteIf(fn func(key TKey, data TData) bool) int {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
if s.data == nil {
|
||||
s.data = make(map[TKey]TData)
|
||||
}
|
||||
|
||||
rm := 0
|
||||
for k, v := range s.data {
|
||||
if fn(k, v) {
|
||||
delete(s.data, k)
|
||||
rm++
|
||||
}
|
||||
}
|
||||
|
||||
return rm
|
||||
}
|
||||
|
||||
func (s *SyncMap[TKey, TData]) Clear() {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
@@ -172,3 +191,14 @@ func (s *SyncMap[TKey, TData]) GetAllValues() []TData {
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (s *SyncMap[TKey, TData]) Count() int {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
if s.data == nil {
|
||||
s.data = make(map[TKey]TData)
|
||||
}
|
||||
|
||||
return len(s.data)
|
||||
}
|
||||
|
Reference in New Issue
Block a user