package engine type sequenceItemProjectionIndex struct { outputByInput map[int]int inputByOutput map[int]int } func newSequenceItemProjectionIndex(projections []sequenceItemProjection) sequenceItemProjectionIndex { index := sequenceItemProjectionIndex{ outputByInput: make(map[int]int, len(projections)), inputByOutput: make(map[int]int, len(projections)), } for _, projection := range projections { if projection.inputIndex >= 0 && projection.outputIndex >= 0 { index.outputByInput[projection.inputIndex] = projection.outputIndex index.inputByOutput[projection.outputIndex] = projection.inputIndex } } return index } func (index sequenceItemProjectionIndex) outputForInput(inputIndex int) (int, bool) { output, found := index.outputByInput[inputIndex] return output, found } func (index sequenceItemProjectionIndex) inputForOutput(outputIndex int) (int, bool) { input, found := index.inputByOutput[outputIndex] return input, found }