Package dsa.lab09.base
Class PriorityQueue.ItemIterator<Priority extends Comparable<Priority>,Item>
java.lang.Object
dsa.lab09.base.PriorityQueue.ItemIterator<Priority,Item>
- Type Parameters:
Priority
- the item typeItem
- the item type
- All Implemented Interfaces:
Iterator<Item>
- Enclosing interface:
PriorityQueue<Priority extends Comparable<Priority>,
Item>
public static class PriorityQueue.ItemIterator<Priority extends Comparable<Priority>,Item>
extends Object
implements Iterator<Item>
An iterator over the items in a priority queue.
Iterates over the items of a given prioritised item iterator.
-
Constructor Summary
ConstructorsConstructorDescriptionItemIterator
(Iterator<PriorityQueueItem<Priority, Item>> prioritisedItemIterator) Construct an iterator over the items in the given prioritised item iterator. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
ItemIterator
Construct an iterator over the items in the given prioritised item iterator.- Parameters:
prioritisedItemIterator
- the iterator over prioritised items
-
-
Method Details
-
hasNext
public boolean hasNext()Check if there are more items to be iterated over.(Equivalently, checks if
next()
would return an item rather than throwing aNoSuchElementException
.) -
next
Get the next item in the iteration.- Specified by:
next
in interfaceIterator<Priority extends Comparable<Priority>>
- Returns:
- the next item
- Throws:
NoSuchElementException
- if there is no next item
-
remove
Remove the previous item returned fromnext()
.- Specified by:
remove
in interfaceIterator<Priority extends Comparable<Priority>>
- Throws:
IllegalStateException
- ifnext()
hasn't yet been called, or ifremove()
has already been called sincenext()
was last called
-