public class PriorityQueueTest
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
private static int |
MAX_NUMBER |
The maximum number of Messages that can be added during a trial
|
private static int |
NUM_PRIORITIES |
The number of priorities in the priority queue data structure we are
using
|
private static int |
NUM_TRIALS |
The number of trials there will be, where a trial represents
creating a PriorityQueue adding the allotted number of Messages, and
removing them as specified in the assignment then analyzing the data
|
private static int |
time |
The current time of a trial/the number of minutes elapsed
since the beginning of a trial
|
private static int |
TIME_TO_PROCESS |
The number of minutes it takes to process one Message
|
private static java.util.ArrayList[] |
waitingTimes |
An ArrayList of the waitingTimes, which will hold all of the waiting
times for each level
|
| Constructor | Description |
|---|---|
PriorityQueueTest() |
| Modifier and Type | Method | Description |
|---|---|---|
private static void |
analyze(int totalMessages) |
Analyzes the trials and prints the pertinent information: the number
of total messages, the final time at the end of the trial, and for
each priority level: average wait times, number of messages,
rate at which messages of that level occurred, and the deviation of that
rate from .2.
|
static void |
main(java.lang.String[] args) |
|
private static void |
process(Message msg) |
Processes msg by calculating the waiting time then adding it to the
correct position (its corresponding priority level) in waitingTimes
|
static void |
trial(int totalMessages) |
Simulates a trial under the following rules: a Message is added every
minute to the priority queue and one is processed from the priority queue
every four minutes.
|
private static int NUM_TRIALS
private static int MAX_NUMBER
private static int NUM_PRIORITIES
private static int TIME_TO_PROCESS
private static int time
private static java.util.ArrayList[] waitingTimes
private static void process(Message msg)
msg - the Message to be processedprivate static void analyze(int totalMessages)
totalMessages - the number of messages in the current trialpublic static void trial(int totalMessages)
totalMessages - the number of Messages to be processed during
the trialpublic static void main(java.lang.String[] args)