adding a test case
[IRC.git] / Robust / src / ClassLibrary / HashMapIterator.java
index 70e1a405ccd52c7a4f43b47b008352c3518e9498..d3516022cb21cd0665b1db95fa2c7a33922c1ebc 100644 (file)
@@ -1,46 +1,51 @@
-class HashMapIterator {
-    HashMap map;
-    int type;
-    int bin;
-    HashEntry he;
+class HashMapIterator extends Iterator {
+  HashMap map;
+  int type;
+  int bin;
+  HashEntry he;
 
-    public HashMapIterator(HashMap map, int type) {
-       this.map=map;
-       this.type=type;
-       this.bin=0;
-       this.he=null;
-    }
+  public HashMapIterator(HashMap map, int type) {
+    this.map=map;
+    this.type=type;
+    this.bin=0;
+    this.he=null;
+  }
 
-    public boolean hasNext() {
-       if (he!=null&&he.next!=null)
-           return true;
-       int i=bin;
-       while((i<map.table.length)&&map.table[i]==null)
-           i++;
-       return (i<map.table.length);
-    }
+  public boolean hasNext() {
+    if (he!=null&&he.next!=null)
+      return true;
+    int i=bin;
+    while((i<map.table.length)&&map.table[i]==null)
+      i++;
+    return (i<map.table.length);
+  }
 
-    public Object next() {
-       if (he!=null&&he.next!=null) {
-           he=he.next;
-           Object o;
-           if (type==0)
-               o=he.key;
-           else
-               o=he.value;
-           return o;
-       }
-       while((bin<map.table.length)&&
-             (map.table[bin]==null))
-           bin++;
-       if (bin<map.table.length) {
-           he=map.table[bin++];
-           Object o;
-           if (type==0)
-               o=he.key;
-           else
-               o=he.value;
-           return o;
-       } else System.error();
+  public Object next() {
+    if (he!=null&&he.next!=null) {
+      he=he.next;
+      Object o;
+      if (type==0)
+        o=he.key;
+      else
+        o=he.value;
+      return o;
     }
+    while((bin<map.table.length)&&
+          (map.table[bin]==null))
+      bin++;
+    if (bin<map.table.length) {
+      he=map.table[bin++];
+      Object o;
+      if (type==0)
+        o=he.key;
+      else
+        o=he.value;
+      return o;
+    } else System.error();
+  }
+
+  public void remove() {
+    System.out.println("HashMapIterator.remove() not implemented.");
+    System.exit(-1);
+  }
 }