X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FGSS.java;h=f222fe568d8e4914540399674279d6e1bd1ac144;hp=f0a4cea21c0f741f4247c0f662192bd1bdfe9840;hb=fc8cad4de7decd07e23f26ccfadb5e6d1ce291d5;hpb=f57e7386abbd8d301f46c0f68a32bffbb1c15253
diff --git a/src/edu/berkeley/sbp/GSS.java b/src/edu/berkeley/sbp/GSS.java
index f0a4cea..f222fe5 100644
--- a/src/edu/berkeley/sbp/GSS.java
+++ b/src/edu/berkeley/sbp/GSS.java
@@ -25,7 +25,7 @@ class GSS {
/** corresponds to a positions between tokens the input stream; same as Tomita's U_i's */
class Phase implements Invokable, IntegerMappable, GraphViz.ToGraphViz, Iterable {
- public ArrayList reductionQueue = new ArrayList();
+ public PriorityQueue reductionQueue = new PriorityQueue();
public void invoke(State st, Result result, Object o) {
//shifts++;
@@ -95,34 +95,8 @@ class GSS {
/** perform all reduction operations */
public void reduce() throws ParseFailed {
- Reduction last = null;
- while(!reductionQueue.isEmpty()) {
- Reduction r = null;
-
- // ugly
- OUTER: for(int i=0; i 0)
- continue OUTER;
- }
- r = reductionQueue.get(i);
- reductionQueue.remove(r);
- break;
- }
-
- /*
- if (last == null) last = r;
- else if (r.compareTo(last) > 0) last = r;
- else if (r.compareTo(last) < 0) {
- if (r.targetPhase() != null)
- System.out.println("err " + last.compareTo(r) + " " + last.targetPhase().pos() +
- " " + r.targetPhase().pos() + " " + pos);
- }
- */
-
- r.perform();
- }
+ while(!reductionQueue.isEmpty())
+ reductionQueue.poll().perform();
}
public void newNodeFromReduction(Result result, State state, boolean fromEmptyReduction, Position reduction) {