diff --git a/pkg/ds/dic/concurrent_map.go b/pkg/ds/dic/concurrent_map.go index 1c04a8c..4843892 100644 --- a/pkg/ds/dic/concurrent_map.go +++ b/pkg/ds/dic/concurrent_map.go @@ -4,17 +4,20 @@ import ( "sync" ) +// ConcurrentDictionary is a thread-safe dictionary. type ConcurrentDictionary[K comparable, V any] struct { m *Dictionary[K, V] l sync.RWMutex } +// NewConcurrentDictionary creates a new ConcurrentDictionary. func NewConcurrentDictionary[K comparable, V any]() *ConcurrentDictionary[K, V] { return &ConcurrentDictionary[K, V]{ m: NewDictionary[K, V](), } } +// Add adds a new item to the dictionary. func (d *ConcurrentDictionary[K, V]) Add(key K, value V) bool { d.l.Lock() defer d.l.Unlock()