| 123456789101112131415161718192021222324252627 |
- package dataStruct
- import "sync"
- type DMapInterface struct {
- RWLock sync.Mutex
- Map *sync.Map
- }
- func NewDMapInterface() *DMapInterface {
- m := &DMapInterface{
- Map: new(sync.Map),
- }
- return m
- }
- func (m *DMapInterface) Add(key interface{}, val interface{}) {
- m.Map.Store(key, val)
- }
- func (m *DMapInterface) Remove(key interface{}) {
- m.Map.Delete(key)
- }
- func (m *DMapInterface) Get(key interface{}) (interface{}, bool) {
- return m.Map.Load(key)
- }
|