text: public Automaton convert(Automaton utf32) {if (utf32.getNumStates() == 0) {return utf32;}int[] map = new int[utf32.getNumStates()];Arrays.fill(map, -1);List<Integer> pending = new ArrayList<>();int utf32State = 0;pending.add(utf32State);utf8 = new Automaton.Builder();int utf8State = utf8.createState();utf8.setAccept(utf8State, utf32.isAccept(utf32State));map[utf32State] = utf8State;Transition scratch = new Transition();while (pending.size() != 0) {utf32State = pending.remove(pending.size()-1);utf8State = map[utf32State];assert utf8State != -1;int numTransitions = utf32.getNumTransitions(utf32State);utf32.initTransition(utf32State, scratch);for(int i=0;i<numTransitions;i++) {utf32.getNextTransition(scratch);int destUTF32 = scratch.dest;int destUTF8 = map[destUTF32];if (destUTF8 == -1) {destUTF8 = utf8.createState();utf8.setAccept(destUTF8, utf32.isAccept(destUTF32));map[destUTF32] = destUTF8;pending.add(destUTF32);}convertOneEdge(utf8State, destUTF8, scratch.min, scratch.max);}}return utf8.finish();}