public class MessagePriorityQueue
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
static int |
NUM_PRIORITIES |
The number of priorities available for this MessagePriorityQueue
|
private java.util.ArrayList<MessageQueue> |
queues |
An ArrayList of MessageQueues which will hold the values for
the priority queue; each MessageQueue represents a priority level
|
| Constructor | Description |
|---|---|
MessagePriorityQueue() |
Constructs a MessagePriorityQueue object by initializing
each queue in the queues field
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
add(Message msg) |
Adds a Message to the MessageQueue at the index of its priority
in queues
|
boolean |
isEmpty() |
Returns whether the queue is empty
|
Message |
peek() |
Returns the highest-priority Message (0 is the highest, 4 is the lowest)
|
Message |
remove() |
Returns and removes the highest-priority Message (0 is the highest,
4 is the lowest)
|
private java.util.ArrayList<MessageQueue> queues
public static final int NUM_PRIORITIES
public MessagePriorityQueue()
public void add(Message msg)
msg - the Message to be addedpublic Message remove()
public Message peek()
public boolean isEmpty()