In the past, I've found it frustrating that the Map interface does not
implement Collection.  So here's an adapter to make a Map look like a
Collection.  Some of the methods really operate on the keySet, but on
the whole it should suit many needs.

New files are attached and patches are below. Junit tests are provided
as well.

Thanks,
Chuck

=============================

Index: src/java/org/apache/commons/collections/package.html
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/collections/src/java/org/apache/commons/collections/package.html,v
retrieving revision 1.4
diff -u -r1.4 package.html
--- src/java/org/apache/commons/collections/package.html        2001/08/29
15:28:07        1.4
+++ src/java/org/apache/commons/collections/package.html        2001/08/29
22:03:11
@@ -74,11 +74,13 @@
           {@link org.apache.commons.collections.ArrayEnumeration}<br>

           {@link org.apache.commons.collections.ArrayIterator}<br>

           {@link
org.apache.commons.collections.EnumerationIterator}<br>

-          {@link org.apache.commons.collections.IteratorEnumeration}

+          {@link
org.apache.commons.collections.IteratorEnumeration}<br>

+          {@link org.apache.commons.collections.MapCollection}

         </td>

         <td valign="top">

           Access Java1-style containers as though they were

-          Java2-style Collections and vice-versa.

+          Java2-style Collections and vice-versa. Also make a Map look

+          like a Collection.

         </td>

       </tr>

       <tr>

Index: src/test/org/apache/commons/collections/TestAll.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/collections/src/test/org/apache/commons/collections/TestAll.java,v
retrieving revision 1.11
diff -u -r1.11 TestAll.java
--- src/test/org/apache/commons/collections/TestAll.java        2001/08/29
15:28:07        1.11
+++ src/test/org/apache/commons/collections/TestAll.java        2001/08/29
22:03:11
@@ -90,6 +90,7 @@
         suite.addTest(TestFastTreeMap1.suite());
         suite.addTest(TestHashBag.suite());
         suite.addTest(TestHashMap.suite());
+        suite.addTest(TestMapCollection.suite());
         suite.addTest(TestSingletonIterator.suite());
         suite.addTest(TestTreeBag.suite());
         suite.addTest(TestTreeMap.suite());


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

MapCollection.tgz

Reply via email to