MCPcopy
hub / github.com/cornelk/hashmap / Range

Method Range

hashmap.go:220–230  ·  view source on GitHub ↗

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

(f func(Key, Value) bool)

Source from the content-addressed store, hash-verified

218// Range calls f sequentially for each key and value present in the map.
219// If f returns false, range stops the iteration.
220func (m *Map[Key, Value]) Range(f func(Key, Value) bool) {
221 item := m.linkedList.First()
222
223 for item != nil {
224 value := item.Value()
225 if !f(item.key, value) {
226 return
227 }
228 item = item.Next()
229 }
230}
231
232func (m *Map[Key, Value]) allocate(newSize uintptr) {
233 m.linkedList = NewList[Key, Value]()

Callers 1

TestRangeFunction · 0.80

Calls 3

FirstMethod · 0.80
ValueMethod · 0.80
NextMethod · 0.80

Tested by 1

TestRangeFunction · 0.64