public class Queue
extends java.lang.Object
implements java.io.Serializable
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.
|
java.lang.Object |
peek()
Gets object from the front of the queue.
|
java.lang.Object |
pop()
Pops an object from the front of the queue.
|
java.lang.Object |
push(java.lang.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.
|
java.lang.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 java.lang.Object push(java.lang.Object item)
item
- the object to be appendedpublic java.lang.Object pop() throws java.lang.RuntimeException
java.lang.RuntimeException
- if the queue is emptypublic java.lang.Object peek() throws java.lang.RuntimeException
java.lang.RuntimeException
- if the queue is emptypublic boolean empty()
public int size()
public java.lang.String toString()
toString
in class java.lang.Object