1 50 package org.apache.avalon.excalibur.collections; 51 52 import java.util.ArrayList ; 53 import java.util.EmptyStackException ; 54 55 64 public class ArrayStack 65 extends ArrayList 66 { 67 public void setSize( final int size ) 68 { 69 if( 0 == size ) 70 { 71 clear(); 72 } 73 else 74 { 75 removeRange( size, size() - 1 ); 76 } 77 } 78 79 85 public Object push( final Object element ) 86 { 87 add( element ); 88 return element; 89 } 90 91 97 public Object pop() 98 throws EmptyStackException 99 { 100 final int size = size(); 101 if( 0 == size ) 102 { 103 throw new EmptyStackException (); 104 } 105 106 return remove( size - 1 ); 107 } 108 } 109 110 | Popular Tags |