public class PQ3<E>
extends java.lang.Object
Constructor and Description |
---|
PQ3(int capacity)
initializes objects of type PQ3.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addNItems(E[] items)
If the number of items to be added + the current elements would exceed the capacity of the queue, return false.
|
static java.lang.String |
formatOutput(java.lang.Object[] items)
A method to help with testing
|
E[] |
getQueue() |
static void |
main(java.lang.String[] args) |
E[] |
newArray(int capacity) |
E[] |
removeNItems(int n)
If the number of items to remove is larger than the current size of the queue,
return null.
|
void |
setQueue(E[] items)
Sets the queue so that we can decouple testing for the add and remove operations
|
int |
size() |
public PQ3(int capacity)
capacity
- the maximum size of the queuepublic E[] getQueue()
public void setQueue(E[] items)
items
- items for the arraypublic static java.lang.String formatOutput(java.lang.Object[] items)
items
- a list of the items to printpublic E[] newArray(int capacity)
capacity
- the size of the arraypublic E[] removeNItems(int n)
n
- the number of elements to removepublic boolean addNItems(E[] items)
items
- the items to be added to the queuepublic int size()
public static void main(java.lang.String[] args)