X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Futil%2FHash.java;h=11fe4d863bccf19d6a19a1ca6e925c247621248c;hb=fffcafc33aa4066bdf85da7a32e1a1cdb9db2d6f;hp=40cf117f5195a58f73ad32aedb8ad539da560c4b;hpb=3591b88b94a6bb378af3d4abe6eb5233ce583104;p=org.ibex.core.git diff --git a/src/org/ibex/util/Hash.java b/src/org/ibex/util/Hash.java index 40cf117..11fe4d8 100644 --- a/src/org/ibex/util/Hash.java +++ b/src/org/ibex/util/Hash.java @@ -151,23 +151,23 @@ public class Hash { } private class HashEnum implements java.util.Enumeration { - private int iterator = 0; - private int found = 0; + private int iterator; - public HashEnum () { } + 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]; + iterator++; + findNext(); return o; } }