public IntsRef next(){
  if (emitEmptyString) {
    emitEmptyString=false;
    return EMPTY;
  }
  for (int depth=string.length(); depth > 0; ) {
    PathNode node=nodes[depth - 1];
    int label=node.nextLabel(a);
    if (label != -1) {
      string.setIntAt(depth - 1,label);
      int to=node.to;
      if (a.getNumTransitions(to) != 0) {
        if (pathStates.get(to)) {
          throw new IllegalArgumentException("automaton has cycles");
        }
        pathStates.set(to);
        growStack(depth);
        nodes[depth].resetState(a,to);
        depth++;
        string.setLength(depth);
        string.grow(depth);
      }
 else       if (a.isAccept(to)) {
        return string.get();
      }
    }
 else {
      int state=node.state;
      assert pathStates.get(state);
      pathStates.clear(state);
      depth--;
      string.setLength(depth);
      if (a.isAccept(state)) {
        return string.get();
      }
    }
  }
  return null;
}

public IntsRef next ( ) { if ( emitEmptyString ) { emitEmptyString = false ; return EMPTY ; } for ( int depth = string . length ( ) ; depth > 0 ; ) { PathNode node = nodes [ depth - 1 ] ; int label = node . nextLabel ( a ) ; if ( label != - 1 ) { string . setIntAt ( depth - 1 , label ) ; int to = node . to ; if ( a . getNumTransitions ( to ) != 0 ) { if ( pathStates . get ( to ) ) { throw new IllegalArgumentException ( "automaton has cycles" ) ; } pathStates . set ( to ) ; growStack ( depth ) ; nodes [ depth ] . resetState ( a , to ) ; depth ++ ; string . setLength ( depth ) ; string . grow ( depth ) ; } else if ( a . isAccept ( to ) ) { return string . get ( ) ; } } else { int state = node . state ; assert pathStates . get ( state ) ; pathStates . clear ( state ) ; depth -- ; string . setLength ( depth ) ; if ( a . isAccept ( state ) ) { return string . get ( ) ; } } } return null ; }
generate next finite string . the return value is just valid until the next call of this method !
