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

Method first

immutable.go:1536–1559  ·  view source on GitHub ↗

first positions the stack left most index. Elements and indexes at and below the current depth are assumed to be correct.

()

Source from the content-addressed store, hash-verified

1534// first positions the stack left most index.
1535// Elements and indexes at and below the current depth are assumed to be correct.
1536func (itr *MapIterator[K, V]) first() {
1537 for ; ; itr.depth++ {
1538 elem := &itr.stack[itr.depth]
1539
1540 switch node := elem.node.(type) {
1541 case *mapBitmapIndexedNode[K, V]:
1542 elem.index = 0
1543 itr.stack[itr.depth+1].node = node.nodes[0]
1544
1545 case *mapHashArrayNode[K, V]:
1546 for i := 0; i < len(node.nodes); i++ {
1547 if node.nodes[i] != nil { // find first node
1548 elem.index = i
1549 itr.stack[itr.depth+1].node = node.nodes[i]
1550 break
1551 }
1552 }
1553
1554 default: // *mapArrayNode, mapLeafNode
1555 elem.index = 0
1556 return
1557 }
1558 }
1559}
1560
1561// mapIteratorElem represents a node/index pair in the MapIterator stack.
1562type mapIteratorElem[K, V any] struct {

Callers 2

FirstMethod · 0.95
nextMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected