|
net.datastructures - version 5.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectnet.datastructures.NodeQueue<E>
public class NodeQueue<E>
Realization of a queue by means of a singly-linked list of nodes. All operations are performed in constant time.
| Field Summary | |
|---|---|
protected Node<E> |
head
|
protected int |
size
|
protected Node<E> |
tail
|
| Constructor Summary | |
|---|---|
NodeQueue()
Creates an empty queue. |
|
| Method Summary | |
|---|---|
E |
dequeue()
Removes the element at the front of the queue. |
void |
enqueue(E elem)
Inserts an element at the rear of the queue. |
E |
front()
Inspects the element at the front of the queue. |
boolean |
isEmpty()
Returns whether the queue is empty. |
static void |
main(String[] args)
Test program that performs a series of operations on on a queue and prints the operation performed, the returned element and the content of the stack after each operation. |
int |
size()
Returns the number of elements in the queue. |
static void |
status(Queue Q,
String op,
Object element)
Prints information about an operation and the queue. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Node<E> head
protected Node<E> tail
protected int size
| Constructor Detail |
|---|
public NodeQueue()
| Method Detail |
|---|
public int size()
Queue
size in interface Queue<E>public boolean isEmpty()
Queue
isEmpty in interface Queue<E>public void enqueue(E elem)
Queue
enqueue in interface Queue<E>elem - new element to be inserted.
public E front()
throws EmptyQueueException
Queue
front in interface Queue<E>EmptyQueueException - if the queue is empty.
public E dequeue()
throws EmptyQueueException
Queue
dequeue in interface Queue<E>EmptyQueueException - if the queue is empty.public String toString()
toString in class Object
public static void status(Queue Q,
String op,
Object element)
op - operation performedelement - element returned by the operationpublic static void main(String[] args)
|
net.datastructures - version 5.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||