Source of 26.47.java


  1: // @author Frank M. Carrano, Timothy M. Henry
  2: // @version 5.0
  3: public Iterator<K> getKeyIterator()
  4: {
  5:    return new KeyIterator();
  6: } // end getKeyIterator

  8: private class KeyIterator implements Iterator<K>
  9: {
 10:    Iterator<Entry<K, V>> localIterator;
 11:    
 12:    public KeyIterator()
 13:    {
 14:       localIterator = bst.getInorderIterator();
 15:    } // end default constructor
 16:    
 17:    public boolean hasNext()
 18:    {
 19:       return localIterator.hasNext();
 20:    } // end hasNext
 21:    
 22:    public K next()
 23:    {
 24:       Entry<K, V> nextEntry = localIterator.next();
 25:       return nextEntry.getKey();
 26:    } // end next
 27:    
 28:    public void remove()
 29:    {
 30:       throw new UnsupportedOperationException();
 31:    } // end remove
 32: } // end KeyIterator