Subversion Repositories programming

Rev

Rev 26 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
24 irasnyd 1
//Written by Ira Snyder
2
//11-03-2004
3
 
4
import java.util.LinkedList;
5
 
6
class Queue {
26 irasnyd 7
    private LinkedList list;
24 irasnyd 8
 
26 irasnyd 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(); }
24 irasnyd 19
 
26 irasnyd 20
    //check if the queue is empty
21
    public boolean isEmpty() { return list.isEmpty(); }
24 irasnyd 22
}
23