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

Method last

immutable.go:2189–2203  ·  view source on GitHub ↗

last positions the stack to the rightmost key from the current depth. Elements and indexes below the current depth are assumed to be correct.

()

Source from the content-addressed store, hash-verified

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.
2189func (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.

Callers 2

LastMethod · 0.95
prevMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected