enumerate arrays in order
authorbrian <brian@brianweb.net>
Tue, 6 Apr 2004 22:18:32 +0000 (22:18 +0000)
committerbrian <brian@brianweb.net>
Tue, 6 Apr 2004 22:18:32 +0000 (22:18 +0000)
darcs-hash:20040406221832-24bed-8de747278674da5068153a44fbf3e14479af1b0a.gz

src/org/ibex/js/JSArray.java

index bf54947..7b90de7 100644 (file)
@@ -99,11 +99,11 @@ public class JSArray extends JS {
 
     public Enumeration keys() {
         return new Enumeration() {
-                private 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);
                 }
             };
     }