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)
| 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. |
| 2075 | func (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. |