package dataStructures; /** *

Titulo: Uma implementaçao vectorial da Pilha Ilimitada

*

Descrição: Esta implementaçao usa um vector de dimensão crescente

* @version 1.0 */ public class VStack implements Stack,Cloneable { private final int DELTA = 128; private Object[] theStack; private int theTop; public VStack() { theStack = new Object[DELTA]; theTop = -1; } public Stack empty() { return new VStack(); } public boolean isEmpty() { return theTop == -1; } /** * Increments the structure length (adds 'DELTA' new slots) */ private void grow() { Object[] newStack = new Object[theStack.length + DELTA]; for(int i=0;i"; } //******************************************************************** public static void main(String[] args) { VStack v1 = new VStack(), v2 = new VStack(); v1.push(new Integer(3)); v1.push(new Integer(4)); v1.push(new Integer(5)); v1.push(new Integer(6)); v1.push(new Integer(7)); v2.push(new Integer(1)); v1.pop(); System.out.println(v1 + " " + v2.clone()); System.out.println(v1.equals(v2) ? "==" : "!="); } } // endClass VStack