v0.0.447
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m18s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m18s
This commit is contained in:
parent
567ead8697
commit
631006a4e1
@ -35,6 +35,23 @@ func (s *SyncMap[TKey, TData]) SetIfNotContains(key TKey, data TData) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *SyncMap[TKey, TData]) SetIfNotContainsFunc(key TKey, data func() TData) bool {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
if s.data == nil {
|
||||
s.data = make(map[TKey]TData)
|
||||
}
|
||||
|
||||
if _, existsInPreState := s.data[key]; existsInPreState {
|
||||
return false
|
||||
}
|
||||
|
||||
s.data[key] = data()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *SyncMap[TKey, TData]) Get(key TKey) (TData, bool) {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
@ -66,6 +83,23 @@ func (s *SyncMap[TKey, TData]) GetAndSetIfNotContains(key TKey, data TData) TDat
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SyncMap[TKey, TData]) GetAndSetIfNotContainsFunc(key TKey, data func() TData) TData {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
if s.data == nil {
|
||||
s.data = make(map[TKey]TData)
|
||||
}
|
||||
|
||||
if v, ok := s.data[key]; ok {
|
||||
return v
|
||||
} else {
|
||||
dataObj := data()
|
||||
s.data[key] = dataObj
|
||||
return dataObj
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SyncMap[TKey, TData]) Delete(key TKey) bool {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
@ -1,5 +1,5 @@
|
||||
package goext
|
||||
|
||||
const GoextVersion = "0.0.446"
|
||||
const GoextVersion = "0.0.447"
|
||||
|
||||
const GoextVersionTimestamp = "2024-05-10T21:31:36+0200"
|
||||
const GoextVersionTimestamp = "2024-05-10T21:33:01+0200"
|
||||
|
Loading…
Reference in New Issue
Block a user