@@ -26,7 +26,7 @@ func NewConcurrentMap() ConcurrentMap {
26
26
return m
27
27
}
28
28
29
- // Returns shard under given key
29
+ // GetShard returns shard under given key
30
30
func (m ConcurrentMap ) GetShard (key string ) * ConcurrentMapShared {
31
31
return m [uint (fnv32 (key ))% uint (SHARD_COUNT )]
32
32
}
@@ -79,7 +79,7 @@ func (m ConcurrentMap) SetIfAbsent(key string, value interface{}) bool {
79
79
return ! ok
80
80
}
81
81
82
- // Retrieves an element from map under given key.
82
+ // Get retrieves an element from map under given key.
83
83
func (m ConcurrentMap ) Get (key string ) (interface {}, bool ) {
84
84
// Get shard
85
85
shard := m .GetShard (key )
@@ -90,7 +90,7 @@ func (m ConcurrentMap) Get(key string) (interface{}, bool) {
90
90
return val , ok
91
91
}
92
92
93
- // Returns the number of elements within the map.
93
+ // Count returns the number of elements within the map.
94
94
func (m ConcurrentMap ) Count () int {
95
95
count := 0
96
96
for i := 0 ; i < SHARD_COUNT ; i ++ {
@@ -113,7 +113,7 @@ func (m ConcurrentMap) Has(key string) bool {
113
113
return ok
114
114
}
115
115
116
- // Removes an element from the map.
116
+ // Remove removes an element from the map.
117
117
func (m ConcurrentMap ) Remove (key string ) {
118
118
// Try to get shard.
119
119
shard := m .GetShard (key )
@@ -122,7 +122,7 @@ func (m ConcurrentMap) Remove(key string) {
122
122
shard .Unlock ()
123
123
}
124
124
125
- // Removes an element from the map and returns it
125
+ // Pop removes an element from the map and returns it
126
126
func (m ConcurrentMap ) Pop (key string ) (v interface {}, exists bool ) {
127
127
// Try to get shard.
128
128
shard := m .GetShard (key )
@@ -133,7 +133,7 @@ func (m ConcurrentMap) Pop(key string) (v interface{}, exists bool) {
133
133
return v , exists
134
134
}
135
135
136
- // Checks if map is empty.
136
+ // IsEmpty checks if map is empty.
137
137
func (m ConcurrentMap ) IsEmpty () bool {
138
138
return m .Count () == 0
139
139
}
@@ -144,7 +144,7 @@ type Tuple struct {
144
144
Val interface {}
145
145
}
146
146
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.
148
148
//
149
149
// Deprecated: using IterBuffered() will get a better performence
150
150
func (m ConcurrentMap ) Iter () <- chan Tuple {
@@ -154,7 +154,7 @@ func (m ConcurrentMap) Iter() <-chan Tuple {
154
154
return ch
155
155
}
156
156
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.
158
158
func (m ConcurrentMap ) IterBuffered () <- chan Tuple {
159
159
chans := snapshot (m )
160
160
total := 0
@@ -208,7 +208,7 @@ func fanIn(chans []chan Tuple, out chan Tuple) {
208
208
close (out )
209
209
}
210
210
211
- // Returns all items as map[string]interface{}
211
+ // Items returns all items as map[string]interface{}
212
212
func (m ConcurrentMap ) Items () map [string ]interface {} {
213
213
tmp := make (map [string ]interface {})
214
214
@@ -239,7 +239,7 @@ func (m ConcurrentMap) IterCb(fn IterCb) {
239
239
}
240
240
}
241
241
242
- // Return all keys as []string
242
+ // Keys returns all keys as []string
243
243
func (m ConcurrentMap ) Keys () []string {
244
244
count := m .Count ()
245
245
ch := make (chan string , count )
0 commit comments