**

Prioritized queue class

Solves CPS 2232 programming assignment #2

@author ...

@version ...

*/

import java.util.NoSuchElementException;

public class PrioritizedQueue<T> {

/**

Construct an empty queue

*/

public PrioritizedQueue() {

...

}

/**

Add specified item to the rear of this queue, subject to the

specified priority; lower priority numbers have preference

[Runs in O(n) time]

@param item the item to be added

*/

public void enqueue(T item, int priority) {

...

}

/**

Remove and return the item at the front of this queue

Throw NoSuchElementException if queue is empty

[Runs in O(1) time]

*/

public T dequeue() {

...

}

/**

Determine the number of elements in the queue

[Runs in O(1) time]

@return the number of elements in the queue

*/

public int size() {

...

}

/**

Is the queue empty?

[Runs in O(1) time]

@return true if the queue is empty, false otherwise

*/

public boolean isEmpty() {

...

}

/**

Return the position of the specified item in this queue,

if found, and -1 if not found.

Position 0 is the front of the queue

[Runs in O(n) time]

@param item the item to locate

@return the position of the item, or -1

*/

int positionOf(T item) {

...

}

/**

Clear the queue so that it is now empty

[Runs in O(1) time]

*/

public void clear() {

...

}

/**

Remove the first occurence of the specified item from the queue

Throw NoSuchElementException if item is not in queue

[Runs in O(n) time]

@param item the item to remove

*/

public void remove(T item) {

...

}

/**

Remove all occurences of the specified item from the queue

Throw NoSuchElementException if item is not in queue

[Runs in O(n) time]

@param item the item to remove

*/

public void removeAll(T item) {

...

}

/**

Get the first element in the queue; set the cursor for iteration

[Runs in O(1) time]

@return the first element in the last; null if queue is empty

*/

public T first() {

...

}

/**

Get the next element in the queue, relative to a previous call

[Runs in O(1) time]

@return the next element in the queue; null if no more elements

*/

public T next() {

...

}

}

Prioritized queue class

Solves CPS 2232 programming assignment #2

@author ...

@version ...

*/

import java.util.NoSuchElementException;

public class PrioritizedQueue<T> {

/**

Construct an empty queue

*/

public PrioritizedQueue() {

...

}

/**

Add specified item to the rear of this queue, subject to the

specified priority; lower priority numbers have preference

[Runs in O(n) time]

@param item the item to be added

*/

public void enqueue(T item, int priority) {

...

}

/**

Remove and return the item at the front of this queue

Throw NoSuchElementException if queue is empty

[Runs in O(1) time]

*/

public T dequeue() {

...

}

/**

Determine the number of elements in the queue

[Runs in O(1) time]

@return the number of elements in the queue

*/

public int size() {

...

}

/**

Is the queue empty?

[Runs in O(1) time]

@return true if the queue is empty, false otherwise

*/

public boolean isEmpty() {

...

}

/**

Return the position of the specified item in this queue,

if found, and -1 if not found.

Position 0 is the front of the queue

[Runs in O(n) time]

@param item the item to locate

@return the position of the item, or -1

*/

int positionOf(T item) {

...

}

/**

Clear the queue so that it is now empty

[Runs in O(1) time]

*/

public void clear() {

...

}

/**

Remove the first occurence of the specified item from the queue

Throw NoSuchElementException if item is not in queue

[Runs in O(n) time]

@param item the item to remove

*/

public void remove(T item) {

...

}

/**

Remove all occurences of the specified item from the queue

Throw NoSuchElementException if item is not in queue

[Runs in O(n) time]

@param item the item to remove

*/

public void removeAll(T item) {

...

}

/**

Get the first element in the queue; set the cursor for iteration

[Runs in O(1) time]

@return the first element in the last; null if queue is empty

*/

public T first() {

...

}

/**

Get the next element in the queue, relative to a previous call

[Runs in O(1) time]

@return the next element in the queue; null if no more elements

*/

public T next() {

...

}

}

### Recently Asked Questions

- Unit 4: Present Tenses 1. Which of the following options is a present simple sentence? I eat rice every day. I am eating rice at the moment. I have

- I need assistance with the following question. Please help me.

- Please refer to the attachment to answer this question. This question was created from Online Quizes_5_2 attempt.