}
private class HashEnum implements java.util.Enumeration {
- private int iterator = 0;
- private int found = 0;
+ private int iterator;
+
+ public HashEnum() { findNext(); }
+
+ private void findNext() {
+ while(iterator < keys1.length && (keys1[iterator] == null || keys1[iterator] == placeholder)) iterator++;
+ }
public boolean hasMoreElements() {
- return found < usedslots;
+ return iterator < keys1.length;
}
public Object nextElement() {
- if (!hasMoreElements()) throw new java.util.NoSuchElementException();
-
- Object o = null;
- while (o == null) o = keys1[iterator++];
- if (o == null) throw new IllegalStateException("Didn't find an element, when I should have.");
- found++;
-
+ if (iterator == keys1.length) throw new NoSuchElementException();
+ Object o = keys1[iterator];
+ findNext();
return o;
}
}