Class PriorityQueueIndexRangeDownhill<T>
Object
PriorityQueueIndexRangeDownhill<T>
- Type Parameters:
T
- item-type in priority queue
Implements a priority queue based upon a range of values from 0 to maxValue.
The maximum index value is always taken first and otherwise a FIFO rule applies.
-
Constructor Summary
ConstructorsConstructorDescriptionPriorityQueueIndexRangeDownhill
(int maxPossibleValue) Creates a new priority queue with a specified maximum value. -
Method Summary
-
Constructor Details
-
PriorityQueueIndexRangeDownhill
public PriorityQueueIndexRangeDownhill(int maxPossibleValue) Creates a new priority queue with a specified maximum value.- Parameters:
maxPossibleValue
- the maximum possible index value (inclusive)- Throws:
IllegalArgumentException
- if maxPossibleValue is negative
-
-
Method Details
-
put
Adds an item to the priority queue with a specified index value.- Parameters:
item
- the item to addindexValue
- the priority index value for the item
-
hasNext
public boolean hasNext()Checks if there are any items left in the queue.- Returns:
- true if there are items in the queue, false otherwise
-
nextValue
public int nextValue()Returns the index value of the next item to be retrieved.- Returns:
- the index value of the next item, or -1 if there is no next value
-
get
Retrieves and removes the next item from the queue.- Returns:
- the next item in the queue, or null if the queue is empty
-