Iterator<State> ghostIt = ghost.iterator();
ghostIt.next(); // skip the initial state in the ghost path
int index = 1;
while (ghostIt.hasNext()) {
assert pathIt.hasNext();
State pathState = pathIt.next();
State ghostState = ghostIt.next();
// add an epsilon transition, but disallow reading the next
// character from the search string if it is followed
epsilons.add(new ConstrainedEpsilon(ghostState, pathState, searchFor.charAt(index)));
// set accept state
if (pathState.isAccept()) {
ghostState.setAccept(true);
}
// next char in search string
index++;
}