KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > util > Stack


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: Stack.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.util;
21
22 import java.util.Vector JavaDoc;
23
24
25 /**
26  * DOCUMENT ME!
27  */

28
29 // FIXME: this class seems pretty useless. Why not remove it?
30
public class Stack extends Vector JavaDoc {
31     int maxsize = 0;
32
33     /**
34      * Creates a new Stack object.
35      *
36      * @param maxsize DOCUMENT ME!
37      */

38     public Stack(int maxsize) {
39         this.maxsize = maxsize;
40     }
41
42     /**
43      * DOCUMENT ME!
44      *
45      * @param args DOCUMENT ME!
46      */

47     public static void main(String JavaDoc[] args) {
48     }
49
50     /**
51      * DOCUMENT ME!
52      *
53      * @param object DOCUMENT ME!
54      */

55     public void push(Object JavaDoc object) {
56         insertElementAt(object, 0);
57
58         if (size() == (maxsize + 1)) {
59             removeElementAt(maxsize);
60         }
61     }
62 }
63
Popular Tags