You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/09/15 07:56:23 UTC

svn commit: r815088 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java

Author: bayard
Date: Tue Sep 15 05:56:23 2009
New Revision: 815088

URL: http://svn.apache.org/viewvc?rev=815088&view=rev
Log:
Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956.

Also see the following revisions:

    ------------------------------------------------------------------------
    r468709 | scolebourne | 2006-10-28 10:49:04 -0700 (Sat, 28 Oct 2006) | 1 line
    
    Convert to generics
    ------------------------------------------------------------------------

Modified:
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java?rev=815088&r1=815087&r2=815088&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapIterator.java Tue Sep 15 05:56:23 2009
@@ -17,6 +17,7 @@
 package org.apache.commons.collections;
 
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 /**
  * Defines an iterator that operates over a <code>Map</code>.
@@ -32,21 +33,23 @@
  * to <code>next()</code>, the <code>getValue()</code> method provides direct
  * access to the value. The value can also be set using <code>setValue()</code>.
  * <pre>
- * MapIterator it = map.mapIterator();
+ * MapIterator<String,Integer> it = map.mapIterator();
  * while (it.hasNext()) {
- *   Object key = it.next();
- *   Object value = it.getValue();
- *   it.setValue(newValue);
+ *   String key = it.next();
+ *   Integer value = it.getValue();
+ *   it.setValue(value + 1);
  * }
  * </pre>
- *  
+ *
+ * @param <K> the type of the keys in the map
+ * @param <V> the type of the values in the map
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
  * @author Stephen Colebourne
  */
-public interface MapIterator extends Iterator {
-    
+public interface MapIterator<K, V> extends Iterator<K> {
+
     /**
      * Checks to see if there are more entries still to be iterated.
      *
@@ -58,9 +61,9 @@
      * Gets the next <em>key</em> from the <code>Map</code>.
      *
      * @return the next key in the iteration
-     * @throws java.util.NoSuchElementException if the iteration is finished
+     * @throws NoSuchElementException if the iteration is finished
      */
-    Object next();
+    K next();
 
     //-----------------------------------------------------------------------
     /**
@@ -70,7 +73,7 @@
      * @return the current key
      * @throws IllegalStateException if <code>next()</code> has not yet been called
      */
-    Object getKey();
+    K getKey();
 
     /**
      * Gets the current value, which is the value associated with the last key
@@ -79,7 +82,7 @@
      * @return the current value
      * @throws IllegalStateException if <code>next()</code> has not yet been called
      */
-    Object getValue();
+    V getValue();
 
     //-----------------------------------------------------------------------
     /**
@@ -93,7 +96,7 @@
      *  since the last call to <code>next()</code>
      */
     void remove();
-    
+
     /**
      * Sets the value associated with the current key (optional operation).
      *
@@ -104,6 +107,6 @@
      * @throws IllegalStateException if <code>remove()</code> has been called since the
      *  last call to <code>next()</code>
      */
-    Object setValue(Object value);
+    V setValue(V value);
 
 }