enumerate arrays in order
[org.ibex.core.git] / src / org / ibex / js / JSArray.java
index f29b79a..7b90de7 100644 (file)
@@ -99,11 +99,11 @@ public class JSArray extends JS {
 
     public Enumeration keys() {
         return new Enumeration() {
-                int cur = 0;
-                public boolean hasMoreElements() { return cur >= size(); }
+                private int n = size();
+                public boolean hasMoreElements() { return n > 0; }
                 public Object nextElement() {
-                    if (cur >= size()) throw new NoSuchElementException();
-                    return new Integer(cur++);
+                    if(n == 0) throw new NoSuchElementException();
+                    return new Integer(--n);
                 }
             };
     }