More classes for galois
[IRC.git] / Robust / src / ClassLibrary / MGC / HashMap.java
index 9ec53db3a82af8dba146480ef3b39a4a31f8866d..562ef51d2b2d6de7119483fdd5c207253dd963d5 100644 (file)
@@ -3,6 +3,7 @@ public class HashMap implements Map {
   float loadFactor;
   int numItems;
   int threshold;
+  Collection values;
 
   public HashMap() {
     init(16, 0.75f);
@@ -143,4 +144,36 @@ public class HashMap implements Map {
     table[bin]=he;
     return null;
   }
+  
+  public Collection values()
+  {
+    if (values == null)
+      // We don't bother overriding many of the optional methods, as doing so
+      // wouldn't provide any significant performance advantage.
+      values = new AbstractCollection()
+      {
+        HashMap map;
+        
+        public AbstractCollection(HashMap m) {
+          this.map = map;
+        }
+        
+        public int size()
+        {
+          return size;
+        }
+
+        public Iterator iterator()
+        {
+          // Cannot create the iterator directly, because of LinkedHashMap.
+          return HashMapIterator(map, 1);
+        }
+
+        public void clear()
+        {
+          map.clear();
+        }
+      };
+    return values;
+  }
 }