Subversion Repositories programming

Rev

Rev 100 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
43 irasnyd 1
//Written by Ira Snyder
2
//11-03-2004
108 ira 3
//License: Public Domain (added 07-11-2005)
43 irasnyd 4
 
5
import java.util.LinkedList;
6
 
7
class Queue {
8
    private LinkedList list;
9
 
10
    public Queue( ) { list = new LinkedList(); } //create an empty queue
11
 
12
    //put the item at the back of the queue
13
    public void enqueue( Object o ) { 
14
        if( list.isEmpty() ) { list.add(o); }
15
        else { list.addLast(o); } 
16
    }
17
 
18
    //remove the item from the front of the queue
19
    public Object dequeue() { return list.removeFirst(); }
20
 
21
    //check if the queue is empty
22
    public boolean isEmpty() { return list.isEmpty(); }
23
}
24