Interface Iterator<K,D>

Type Parameters:
K - The type of the keys.
D - The type of the data.
All Known Subinterfaces:
Listiterator<K,D>

public interface Iterator<K,D>

An iterator allows to iterate over all entries of a Map. E.g., the following code prints all entries of a Map to stdout.

 
  Iterator i = someMap.iterator();
  while (i.more()) {
     System.out.println(i.key() + " -> " + i.data());
     i.step();
  } 
  
  // or equivalently,
  
  for (i=someMap.iterator(); i.more(); i.step()) {
      System.out.println(i.key() + " -> " + i.data());
  }    
 

Author:
Rossmanith
See Also:
Map, Map.iterator()

Method Summary
 D data()
          Returns the data of the current entry, if it is valid, cf.
 K key()
          Returns the key of the current entry, if it is valid, cf.
 boolean more()
          Test whether the current entry is valid.
 void step()
          Move to the next entry.
 

Method Detail

step

void step()
Move to the next entry.


more

boolean more()
Test whether the current entry is valid.


key

K key()
Returns the key of the current entry, if it is valid, cf. more().


data

D data()
Returns the data of the current entry, if it is valid, cf. more().