github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/mempool/herocache/backdata/heropool/linkedlist.go (about) 1 package heropool 2 3 // link represents a slice-based doubly linked-list node that 4 // consists of a next and previous poolIndex. 5 // if a link doesn't belong to any state it's next and prev should hold InvalidIndex. 6 type link struct { 7 next EIndex 8 prev EIndex 9 } 10 11 // state represents a doubly linked-list by its head and tail pool indices. 12 // If state has 0 size, its tail's and head's prev and next are treated as invalid and should hold InvalidIndex values. 13 type state struct { 14 head EIndex 15 tail EIndex 16 size uint32 17 } 18 19 // NewStates constructs an array of a doubly linked-lists. 20 func NewStates(numberOfStates int) []state { 21 result := make([]state, numberOfStates) 22 for i := 1; i < numberOfStates; i++ { 23 result[i] = state{head: InvalidIndex, tail: InvalidIndex, size: 0} 24 } 25 return result 26 }