MCPcopy Create free account
hub / github.com/benbjohnson/immutable / Seek

Method Seek

immutable.go:2075–2083  ·  view source on GitHub ↗

Seek moves the iterator position to the given key in the map. If the key does not exist then the next key is used. If no more keys exist then the iteartor is marked as done.

(key K)

Source from the content-addressed store, hash-verified

2073// If the key does not exist then the next key is used. If no more keys exist
2074// then the iteartor is marked as done.
2075func (itr *SortedMapIterator[K, V]) Seek(key K) {
2076 if itr.m.root == nil {
2077 itr.depth = -1
2078 return
2079 }
2080 itr.stack[0] = sortedMapIteratorElem[K, V]{node: itr.m.root}
2081 itr.depth = 0
2082 itr.seek(key)
2083}
2084
2085// Next returns the current key/value pair and moves the iterator forward.
2086// Returns a nil key if the there are no more elements to return.

Callers 2

TestListFunction · 0.45
TestSortedMap_IteratorFunction · 0.45

Calls 1

seekMethod · 0.95

Tested by 2

TestListFunction · 0.36
TestSortedMap_IteratorFunction · 0.36