public class Queue extends Object implements Serializable, RevisionHandler
Modifier and Type | Class and Description |
---|---|
protected class |
Queue.QueueNode
Represents one node in the queue.
|
Modifier and Type | Field and Description |
---|---|
protected Queue.QueueNode |
m_Head
Store a reference to the head of the queue
|
protected int |
m_Size
Store the c m_Tail.m_Nexturrent number of elements in the queue
|
protected Queue.QueueNode |
m_Tail
Store a reference to the tail of the queue
|
Constructor and Description |
---|
Queue() |
Modifier and Type | Method and Description |
---|---|
boolean |
empty()
Checks if queue is empty.
|
String |
getRevision()
Returns the revision string.
|
static void |
main(String[] argv)
Main method for testing this class.
|
Object |
peek()
Gets object from the front of the queue.
|
Object |
pop()
Pops an object from the front of the queue.
|
Object |
push(Object item)
Appends an object to the back of the queue.
|
void |
removeAllElements()
Removes all objects from the queue m_Tail.m_Next.
|
int |
size()
Gets queue's size.
|
String |
toString()
Produces textual description of queue.
|
protected Queue.QueueNode m_Head
protected Queue.QueueNode m_Tail
protected int m_Size
public final void removeAllElements()
public Object push(Object item)
item
- the object to be appendedpublic Object pop() throws RuntimeException
RuntimeException
- if the queue is emptypublic Object peek() throws RuntimeException
RuntimeException
- if the queue is emptypublic boolean empty()
public int size()
public String toString()
public String getRevision()
getRevision
in interface RevisionHandler
public static void main(String[] argv)
argv
- a set of strings that are pushed on a test queueCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.