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 ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815088 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cb26da928c
commit
80eb00cfc5
|
@ -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 @@ import java.util.Iterator;
|
|||
* 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 @@ public interface MapIterator extends Iterator {
|
|||
* 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 @@ public interface MapIterator extends Iterator {
|
|||
* @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 @@ public interface MapIterator extends Iterator {
|
|||
* @return the current value
|
||||
* @throws IllegalStateException if <code>next()</code> has not yet been called
|
||||
*/
|
||||
Object getValue();
|
||||
V getValue();
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -93,7 +96,7 @@ public interface MapIterator extends Iterator {
|
|||
* since the last call to <code>next()</code>
|
||||
*/
|
||||
void remove();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value associated with the current key (optional operation).
|
||||
*
|
||||
|
@ -104,6 +107,6 @@ public interface MapIterator extends Iterator {
|
|||
* @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);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue