From 859663e2a35e4e1f61743073de796dde521cb1b7 Mon Sep 17 00:00:00 2001 From: brian Date: Thu, 20 May 2004 04:05:12 +0000 Subject: [PATCH] js delete key fix darcs-hash:20040520040512-24bed-6e83fedd64ae1bfe845046dc0fad8fb2a1407f87.gz --- src/org/ibex/util/Hash.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/org/ibex/util/Hash.java b/src/org/ibex/util/Hash.java index 4b38870..4ee02c8 100644 --- a/src/org/ibex/util/Hash.java +++ b/src/org/ibex/util/Hash.java @@ -151,21 +151,22 @@ public class Hash { } 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; } } -- 1.7.10.4