KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > client > grapheditor > Queue


1 /*
2  * @(#)Queue.java 1.0 02/02/01
3  *
4  * Copyright (C) 2001 Gaudenz Alder
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */

21
22 package hero.client.grapheditor;
23
24 import java.util.Vector JavaDoc;
25
26 /**
27  * Class to implement a simple queue of integers.
28
29  * </p>Here is the <a HREF="../algorithm/shawn/Queue.java">source</a>.
30  */

31
32 public class Queue
33   {
34    private static int size;
35    Vector JavaDoc array;
36
37    public Queue()
38      {
39       array = new Vector JavaDoc();
40      }
41
42    public int push(int item)
43      {
44       int num;
45       array.addElement(new Integer JavaDoc(item));
46       num = array.size();
47       return num;
48      }
49
50    public int pop()
51      {
52       int item;
53       item = ((Integer JavaDoc)array.elementAt(0)).intValue();
54       array.removeElementAt(0);
55       return item;
56      }
57
58    public boolean isEmpty()
59      {
60       return(array.isEmpty());
61      }
62   }
63
Popular Tags