csc313.hw1
Class CountablesIterator

java.lang.Object
  |
  +--csc313.hw1.CountablesIterator

public class CountablesIterator
extends Object

This class is an iterator that allows sequential access to each entry and its count within a SetOfCountables object.


Constructor Summary
CountablesIterator(SetOfCountables currentSet)
          This constructs an iterators for the given SetOfCountables object.
 
Method Summary
 int getCurrentCount()
          This method gets the number of times the current item (i.e.
 boolean hasNext()
          This method checks if there is another counted item in the set.
 Object next()
          This method advances the iterator to the next item in the set and returns that item.
 void remove()
          This method is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountablesIterator

public CountablesIterator(SetOfCountables currentSet)
This constructs an iterators for the given SetOfCountables object.
Parameters:
currentSet - any initialized SetOfCountables object
Method Detail

hasNext

public boolean hasNext()
This method checks if there is another counted item in the set.
Returns:
true if the iterator still has another counted item to be retrieved
Throws:
ConcurrentModificationException - if the countable set has been modified (using countElement) since the iterator was created

next

public Object next()
This method advances the iterator to the next item in the set and returns that item.
Returns:
the next item
Throws:
NoSuchElementException - if the iterator has already advanced past the last item in the set

getCurrentCount

public int getCurrentCount()
This method gets the number of times the current item (i.e. the object most recently retrieved using next) has been counted.
Returns:
the count of the current item
Throws:
NoSuchElementException - if the iterator has not advanced to a current item

remove

public void remove()
This method is not supported.
Throws:
UnsupportedOperationException - if this method is called