State newstate ( int flag ) { State newState = new State ( ) ; newState . no = nstates ++ ; // a unique number. if ( states == null ) { states = newState ; } if ( slast != null ) { assert slast . next == null ; slast . next = newState ; } newState . prev = slast ; slast = newState ; newState . flag = flag ; return newState ; }
Factory method for new states .