last positions the stack to the rightmost key from the current depth. Elements and indexes below the current depth are assumed to be correct.
()
| 2187 | // last positions the stack to the rightmost key from the current depth. |
| 2188 | // Elements and indexes below the current depth are assumed to be correct. |
| 2189 | func (itr *SortedMapIterator[K, V]) last() { |
| 2190 | for { |
| 2191 | elem := &itr.stack[itr.depth] |
| 2192 | |
| 2193 | switch node := elem.node.(type) { |
| 2194 | case *sortedMapBranchNode[K, V]: |
| 2195 | elem.index = len(node.elems) - 1 |
| 2196 | itr.stack[itr.depth+1] = sortedMapIteratorElem[K, V]{node: node.elems[elem.index].node} |
| 2197 | itr.depth++ |
| 2198 | case *sortedMapLeafNode[K, V]: |
| 2199 | elem.index = len(node.entries) - 1 |
| 2200 | return |
| 2201 | } |
| 2202 | } |
| 2203 | } |
| 2204 | |
| 2205 | // seek positions the stack to the given key from the current depth. |
| 2206 | // Elements and indexes below the current depth are assumed to be correct. |