Author: j16sdiz
Date: 2008-04-14 08:24:36 +0000 (Mon, 14 Apr 2008)
New Revision: 19308

Modified:
   trunk/freenet/src/freenet/support/WeakHashSet.java
Log:
use java.util.AbstractSet


Modified: trunk/freenet/src/freenet/support/WeakHashSet.java
===================================================================
--- trunk/freenet/src/freenet/support/WeakHashSet.java  2008-04-14 08:24:15 UTC 
(rev 19307)
+++ trunk/freenet/src/freenet/support/WeakHashSet.java  2008-04-14 08:24:36 UTC 
(rev 19308)
@@ -1,12 +1,11 @@
 package freenet.support;

+import java.util.AbstractSet;
 import java.util.Collection;
 import java.util.Iterator;
-import java.util.Set;
 import java.util.WeakHashMap;

-public class WeakHashSet implements Set {
-       
+public class WeakHashSet extends AbstractSet {
        private final WeakHashMap map;

        public WeakHashSet() {
@@ -17,14 +16,6 @@
                return map.put(key, null) == null;
        }

-       public boolean addAll(Collection arg0) {
-               boolean changed = false;
-               for(Iterator i=arg0.iterator();i.hasNext();) {
-                       changed |= add(i.next());
-               }
-               return changed;
-       }
-
        public void clear() {
                map.clear();
        }
@@ -34,10 +25,7 @@
        }

        public boolean containsAll(Collection arg0) {
-               for(Iterator i=arg0.iterator();i.hasNext();) {
-                       if(!map.containsKey(i.next())) return false;
-               }
-               return true;
+               return map.keySet().containsAll(arg0);
        }

        public boolean isEmpty() {
@@ -52,19 +40,6 @@
                return map.remove(key) != null;
        }

-       public boolean removeAll(Collection arg0) {
-               boolean changed = false;
-               for(Iterator i=arg0.iterator();i.hasNext();) {
-                       changed |= remove(i.next());
-               }
-               return changed;
-       }
-
-       public boolean retainAll(Collection arg0) {
-               // FIXME
-               throw new UnsupportedOperationException();
-       }
-
        public int size() {
                return map.size();
        }
@@ -76,5 +51,4 @@
        public Object[] toArray(Object[] arg0) {
                return map.keySet().toArray(arg0);
        }
-
 }


Reply via email to