public class VectorStack
1: import java.util.Vector;
2: /**
3: A class of stacks whose entries are stored in a vector.
4: @author Frank M. Carrano and Timothy M. Henry
5: @version 4.0
6: */
7: public class VectorStack<T> implements StackInterface<T>
8: {
9: private Vector<T> stack; // Last element is the top entry in stack
10: private boolean initialized = false;
11: private static final int DEFAULT_CAPACITY = 50;
12: private static final int MAX_CAPACITY = 10000;
13:
14: public VectorStack()
15: {
16: this(DEFAULT_CAPACITY);
17: } // end default constructor
18:
19: public VectorStack(int initialCapacity)
20: {
21: checkCapacity(initialCapacity);
22: stack = new Vector<>(initialCapacity); // Size doubles as needed
23: initialized = true;
24: } // end constructor
25:
26: // < Implementations of checkInitialization, checkCapacity, and the stack
27: // operations go here. >
28: // . . .
29: } // end VectorStack