func (a *SparseAutomaton) Step(state sparseVector, c byte) sparseVector {

	newVec := make(sparseVector, 0)

	if len(state) > 0 && state[0].idx == 0 && state[0].val < a.max {
		newVec = newVec.append(0, state[0].val+1)
	}
	for j, entry := range state {

		if entry.idx == len(a.str) {
			break
		}

		cost := 0
		if a.str[entry.idx] != c {
			cost = 1
		}

		val := state[j].val + cost

		if len(newVec) != 0 && newVec[len(newVec)-1].idx == entry.idx {
			val = min(val, newVec[len(newVec)-1].val+1)
		}

		if len(state) > j+1 && state[j+1].idx == entry.idx+1 {
			val = min(val, state[j+1].val+1)
		}

		if val <= a.max {
			newVec = newVec.append(entry.idx+1, val)
		}

	}
	return newVec
}
// Step returns the next state of the automaton given a previous state and a character to check
Step returns the next state of the automaton given a previous state and a character to check
// Step returns the next state of the automaton given a previous state and a character to check
func (a *SparseAutomaton) Step(state sparseVector, c byte) sparseVector {
	newVec := make(sparseVector, 0)
	if len(state) > 0 && state[0].idx == 0 && state[0].val < a.max {
		newVec = newVec.append(0, state[0].val+1)
	}
	for j, entry := range state {
		if entry.idx == len(a.str) {
			break
		}
		cost := 0
		if a.str[entry.idx] != c {
			cost = 1
		}
		val := state[j].val + cost
		if len(newVec) != 0 && newVec[len(newVec)-1].idx == entry.idx {
			val = min(val, newVec[len(newVec)-1].val+1)
		}
		if len(state) > j+1 && state[j+1].idx == entry.idx+1 {
			val = min(val, state[j+1].val+1)
		}
		if val <= a.max {
			newVec = newVec.append(entry.idx+1, val)
		}
	}
	return newVec
}
func ( a * SparseAutomaton ) Step ( state sparseVector , c byte ) sparseVector { newVec := make ( sparseVector , 0 ) if len ( state ) > 0 && state [ 0 ] . idx == 0 && state [ 0 ] . val < a . max { newVec = newVec . append ( 0 , state [ 0 ] . val + 1 ) } for j , entry := range state { if entry . idx == len ( a . str ) { break } cost := 0 if a . str [ entry . idx ] != c { cost = 1 } val := state [ j ] . val + cost if len ( newVec ) != 0 && newVec [ len ( newVec ) - 1 ] . idx == entry . idx { val = min ( val , newVec [ len ( newVec ) - 1 ] . val + 1 ) } if len ( state ) > j + 1 && state [ j + 1 ] . idx == entry . idx + 1 { val = min ( val , state [ j + 1 ] . val + 1 ) } if val <= a . max { newVec = newVec . append ( entry . idx + 1 , val ) } } return newVec }
Step returns the next state of the automaton given a previous state and a character to check
Step returns the next state of the automaton given a previous state and a character to check