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);
}
};
}