|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.datastructures.NodeQueue
Realization of a queue by means of a singly-linked list of nodes. All operations are performed in constant time.
Field Summary | |
protected Node |
head
|
protected int |
size
|
protected Node |
tail
|
Constructor Summary | |
NodeQueue()
Creates an empty queue. |
Method Summary | |
Object |
dequeue()
Removes the element at the front of the queue. |
void |
enqueue(Object obj)
Inserts an element at the rear of the queue. |
Object |
front()
Inspects the element at the front of the queue. |
boolean |
isEmpty()
Returns whether the queue is empty. |
int |
size()
Returns the number of elements in 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 head
protected Node tail
protected int size
Constructor Detail |
public NodeQueue()
Method Detail |
public int size()
Queue
size
in interface Queue
public boolean isEmpty()
Queue
isEmpty
in interface Queue
public void enqueue(Object obj)
Queue
enqueue
in interface Queue
obj
- new element to be inserted.public Object front() throws EmptyQueueException
Queue
front
in interface Queue
EmptyQueueException
- if the queue is empty.public Object dequeue() throws EmptyQueueException
Queue
dequeue
in interface Queue
EmptyQueueException
- if the queue is empty.public String toString()
|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |