Go to most recent revision |
Details |
Last modification |
View Log
| RSS feed
| Rev |
Author |
Line No. |
Line |
| 33 |
irasnyd |
1 |
//Written by Ira Snyder
|
|
|
2 |
//11-03-2004
|
|
|
3 |
|
|
|
4 |
import java.util.LinkedList;
|
|
|
5 |
|
|
|
6 |
class Queue {
|
|
|
7 |
private LinkedList list;
|
|
|
8 |
|
|
|
9 |
public Queue( ) { list = new LinkedList(); } //create an empty queue
|
|
|
10 |
|
|
|
11 |
//put the item at the back of the queue
|
|
|
12 |
public void enqueue( Object o ) {
|
|
|
13 |
if( list.isEmpty() ) { list.add(o); }
|
|
|
14 |
else { list.addLast(o); }
|
|
|
15 |
}
|
|
|
16 |
|
|
|
17 |
//remove the item from the front of the queue
|
|
|
18 |
public Object dequeue() { return list.removeFirst(); }
|
|
|
19 |
|
|
|
20 |
//check if the queue is empty
|
|
|
21 |
public boolean isEmpty() { return list.isEmpty(); }
|
|
|
22 |
}
|
|
|
23 |
|