Skip to content

Commit

Permalink
docs: comment
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinZonda committed Dec 7, 2022
1 parent 659ce61 commit 31dd275
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/ds/dic/concurrent_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 31dd275

Please sign in to comment.