Java Reference
In-Depth Information
1 /**
2 * Class used to iterate through key set view.
3 * Delegates to an underlying entry set iterator.
4 */
5 private class KeySetIterator implements Iterator<KeyType>
6 {
7 private Iterator<Map.Entry<KeyType,ValueType>> itr = theSet.iterator( );
8
9 public boolean hasNext( )
10 { return itr.hasNext( ); }
11
12 public void remove( )
13 { itr.remove( ); }
14
15 public KeyType next( )
16 { return itr.next( ).getKey( ); }
17 }
18
19 /**
20 * Class used to iterate through value collection view.
21 * Delegates to an underlying entry set iterator.
22 */
23 private class ValueCollectionIterator implements Iterator<ValueType>
24 {
25 private Iterator<Map.Entry<KeyType,ValueType>> itr = theSet.iterator( );
26
27 public boolean hasNext( )
28 { return itr.hasNext( ); }
29
30 public void remove( )
31 { itr.remove( ); }
32
33 public ValueType next( )
34 { return itr.next( ).getValue( ); }
35 }
figure 19.81
View iterator classes
Search WWH ::




Custom Search