Documentation ¶
Index ¶
- type SyncMap
- func (sm *SyncMap[K, V]) Atom(handle func(m map[K]V))
- func (sm *SyncMap[K, V]) Clear()
- func (sm *SyncMap[K, V]) ClearHandle(handle func(key K, value V))
- func (sm *SyncMap[K, V]) Delete(key K)
- func (sm *SyncMap[K, V]) DeleteExist(key K) bool
- func (sm *SyncMap[K, V]) DeleteGet(key K) V
- func (sm *SyncMap[K, V]) DeleteGetExist(key K) (V, bool)
- func (sm *SyncMap[K, V]) Exist(key K) bool
- func (sm *SyncMap[K, V]) Get(key K) V
- func (sm *SyncMap[K, V]) GetExist(key K) (V, bool)
- func (sm *SyncMap[K, V]) Keys() []K
- func (sm *SyncMap[K, V]) Map() map[K]V
- func (sm *SyncMap[K, V]) MarshalJSON() ([]byte, error)
- func (sm *SyncMap[K, V]) Range(handle func(key K, value V) bool)
- func (sm *SyncMap[K, V]) Set(key K, value V)
- func (sm *SyncMap[K, V]) Size() int
- func (sm *SyncMap[K, V]) Slice() []V
- func (sm *SyncMap[K, V]) UnmarshalJSON(bytes []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SyncMap ¶
type SyncMap[K comparable, V any] struct { // contains filtered or unexported fields }
SyncMap 是基于 sync.RWMutex 实现的线程安全的 map
- 适用于要考虑并发读写但是并发读写的频率不高的情况
func NewSyncMap ¶
func NewSyncMap[K comparable, V any](source ...map[K]V) *SyncMap[K, V]
NewSyncMap 创建一个 SyncMap
func (*SyncMap[K, V]) ClearHandle ¶
func (sm *SyncMap[K, V]) ClearHandle(handle func(key K, value V))
ClearHandle 清空并处理
func (*SyncMap[K, V]) DeleteExist ¶
DeleteExist 删除一个值并返回是否存在
func (*SyncMap[K, V]) DeleteGetExist ¶
DeleteGetExist 删除一个值并返回是否存在
func (*SyncMap[K, V]) MarshalJSON ¶
func (*SyncMap[K, V]) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.