Skip to content

Commit b42099c

Browse files
committed
Fix function comments based on best practices from Effective Go
Signed-off-by: CodeLingo Bot <[email protected]>
1 parent 65b7d65 commit b42099c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

utils/map.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func NewConcurrentMap() ConcurrentMap {
2626
return m
2727
}
2828

29-
// Returns shard under given key
29+
// GetShard returns shard under given key
3030
func (m ConcurrentMap) GetShard(key string) *ConcurrentMapShared {
3131
return m[uint(fnv32(key))%uint(SHARD_COUNT)]
3232
}
@@ -79,7 +79,7 @@ func (m ConcurrentMap) SetIfAbsent(key string, value interface{}) bool {
7979
return !ok
8080
}
8181

82-
// Retrieves an element from map under given key.
82+
// Get retrieves an element from map under given key.
8383
func (m ConcurrentMap) Get(key string) (interface{}, bool) {
8484
// Get shard
8585
shard := m.GetShard(key)
@@ -90,7 +90,7 @@ func (m ConcurrentMap) Get(key string) (interface{}, bool) {
9090
return val, ok
9191
}
9292

93-
// Returns the number of elements within the map.
93+
// Count returns the number of elements within the map.
9494
func (m ConcurrentMap) Count() int {
9595
count := 0
9696
for i := 0; i < SHARD_COUNT; i++ {
@@ -113,7 +113,7 @@ func (m ConcurrentMap) Has(key string) bool {
113113
return ok
114114
}
115115

116-
// Removes an element from the map.
116+
// Remove removes an element from the map.
117117
func (m ConcurrentMap) Remove(key string) {
118118
// Try to get shard.
119119
shard := m.GetShard(key)
@@ -122,7 +122,7 @@ func (m ConcurrentMap) Remove(key string) {
122122
shard.Unlock()
123123
}
124124

125-
// Removes an element from the map and returns it
125+
// Pop removes an element from the map and returns it
126126
func (m ConcurrentMap) Pop(key string) (v interface{}, exists bool) {
127127
// Try to get shard.
128128
shard := m.GetShard(key)
@@ -133,7 +133,7 @@ func (m ConcurrentMap) Pop(key string) (v interface{}, exists bool) {
133133
return v, exists
134134
}
135135

136-
// Checks if map is empty.
136+
// IsEmpty checks if map is empty.
137137
func (m ConcurrentMap) IsEmpty() bool {
138138
return m.Count() == 0
139139
}
@@ -144,7 +144,7 @@ type Tuple struct {
144144
Val interface{}
145145
}
146146

147-
// Returns an iterator which could be used in a for range loop.
147+
// Iter returns an iterator which could be used in a for range loop.
148148
//
149149
// Deprecated: using IterBuffered() will get a better performence
150150
func (m ConcurrentMap) Iter() <-chan Tuple {
@@ -154,7 +154,7 @@ func (m ConcurrentMap) Iter() <-chan Tuple {
154154
return ch
155155
}
156156

157-
// Returns a buffered iterator which could be used in a for range loop.
157+
// IterBuffered returns a buffered iterator which could be used in a for range loop.
158158
func (m ConcurrentMap) IterBuffered() <-chan Tuple {
159159
chans := snapshot(m)
160160
total := 0
@@ -208,7 +208,7 @@ func fanIn(chans []chan Tuple, out chan Tuple) {
208208
close(out)
209209
}
210210

211-
// Returns all items as map[string]interface{}
211+
// Items returns all items as map[string]interface{}
212212
func (m ConcurrentMap) Items() map[string]interface{} {
213213
tmp := make(map[string]interface{})
214214

@@ -239,7 +239,7 @@ func (m ConcurrentMap) IterCb(fn IterCb) {
239239
}
240240
}
241241

242-
// Return all keys as []string
242+
// Keys returns all keys as []string
243243
func (m ConcurrentMap) Keys() []string {
244244
count := m.Count()
245245
ch := make(chan string, count)

0 commit comments

Comments
 (0)