@@ -1241,10 +1241,11 @@ public void hopcroftremoveUnreachableStates(){
1241
1241
HashSet <State > newStates = (HashSet <State >) this .getInitialStates ().clone ();
1242
1242
HashSet <Transition > transitionstoRemove = new HashSet <>();
1243
1243
HashSet <State > temp ;
1244
+ final HashSet <State > emptySet = new HashSet <>(Collections .<State >emptySet ());
1244
1245
1245
1246
1246
1247
do {
1247
- temp = new HashSet <>( Collections .< State >emptySet () );
1248
+ temp = ( HashSet <State >) emptySet . clone ( );
1248
1249
for (State s : newStates ){
1249
1250
for (String a : getAlphabet (this )){
1250
1251
State to = getOutgoingStatefromTransitionSymbol (s , a );
@@ -1346,20 +1347,18 @@ public void hopcroftMinimize(){
1346
1347
1347
1348
HashSet <State > A = new HashSet <>();
1348
1349
HashSet <State > X ;
1349
- LinkedList <HashSet <State >> listYs ;
1350
- Random r = new Random ();
1350
+ List <HashSet <State >> listYs ;
1351
+ Random r = new Random ();
1351
1352
1352
1353
while (!W .isEmpty ()){
1353
1354
//choose and remove a set A from W
1354
- do {
1355
- for (HashSet <State > s : W ){
1356
- int insert =r .nextInt (2 );
1357
- if (insert > 0 )
1358
- A = s ;
1359
- else break ;
1360
- }
1361
- W .remove (A );
1362
- }while (A .isEmpty ());
1355
+
1356
+ for (HashSet <State > s : W ){
1357
+ A = s ;
1358
+ if (r .nextInt (2 ) == 0 )
1359
+ break ;
1360
+ }
1361
+ W .remove (A );
1363
1362
1364
1363
for (String c : getAlphabet (this )){
1365
1364
// select a X set for which a transition in c leads to a state in A
@@ -1414,7 +1413,6 @@ private void constructMinimumAutomatonFromPartition(HashSet<HashSet<State>> P) {
1414
1413
isInitialState = isInitialState || s .isInitialState ();
1415
1414
isFinalState = isFinalState || s .isFinalState ();
1416
1415
1417
-
1418
1416
}
1419
1417
1420
1418
State mergedMacroState = new State (macroStatename , isInitialState , isFinalState );
@@ -1440,7 +1438,9 @@ private void constructMinimumAutomatonFromPartition(HashSet<HashSet<State>> P) {
1440
1438
this .states = new HashSet <State >(automatonStateBinding .values ());
1441
1439
this .delta = newDelta ;
1442
1440
1443
- this .adjacencyList = this .computeAdjacencyList ();
1441
+ for (State s : states ){
1442
+ updateAdjacencyList (s );
1443
+ }
1444
1444
}
1445
1445
1446
1446
/**
0 commit comments