From: brian Date: Tue, 6 Apr 2004 22:18:32 +0000 (+0000) Subject: enumerate arrays in order X-Git-Tag: RC4~39 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=3bddaf5a2a3a9a12362b25560dee469e35649ae0;ds=sidebyside enumerate arrays in order darcs-hash:20040406221832-24bed-8de747278674da5068153a44fbf3e14479af1b0a.gz --- diff --git a/src/org/ibex/js/JSArray.java b/src/org/ibex/js/JSArray.java index bf54947..7b90de7 100644 --- a/src/org/ibex/js/JSArray.java +++ b/src/org/ibex/js/JSArray.java @@ -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); } }; }