|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectBattleFront<T>
public class BattleFront<T extends java.lang.Comparable<T>>
The BattleFront is a generic priority queue that orders elements of type T based on their natural order comparison. It is required that T implements Comparable<T>.
| Field Summary | |
|---|---|
private Node<T> |
head
The head of the queue. |
private int |
size
The current number of elements in the queue. |
| Constructor Summary | |
|---|---|
BattleFront()
Constructor which initializes the head to null, and the current count to 0. |
|
| Method Summary | |
|---|---|
T |
dequeue()
Removes and returns the front element from the queue. |
boolean |
empty()
Indicates if the queue is empty or not. |
void |
enqueue(T element)
Adds an element to the queue based on the priority of the elements. |
boolean |
full()
Indicates if the queue is full or not. |
int |
size()
Indicates how many elements are in the queue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private Node<T extends java.lang.Comparable<T>> head
private int size
| Constructor Detail |
|---|
public BattleFront()
| Method Detail |
|---|
public void enqueue(T element)
enqueue in interface IQueue<T extends java.lang.Comparable<T>>element - The new element to insert into the queue
public T dequeue()
throws UnderflowException
dequeue in interface IQueue<T extends java.lang.Comparable<T>>UnderflowException - If the queue is empty it is created
with the message "There is no one on the battlefront!"public int size()
size in interface IQueue<T extends java.lang.Comparable<T>>public boolean empty()
empty in interface IQueue<T extends java.lang.Comparable<T>>public boolean full()
full in interface IQueue<T extends java.lang.Comparable<T>>
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||