1 23 24 29 42 43 48 49 package com.sun.enterprise.util.collection; 50 51 import java.util.ArrayList ; 52 53 54 61 public class FastStack { 62 63 private ArrayList stack; 64 65 68 public FastStack() { 69 stack = new ArrayList (4); 70 } 71 72 76 public boolean empty() { 77 return (stack.size() == 0); 78 } 79 80 84 public boolean isEmpty() { 85 return (stack.size() == 0); 86 } 87 88 93 public Object peek() { 94 if (stack.size() == 0) 95 throw new java.util.EmptyStackException (); 96 return stack.get(stack.size()-1); 97 } 98 99 103 public void push(Object object) { 104 stack.add(object); 105 } 106 107 112 public Object pop() { 113 if (stack.size() == 0) 114 throw new java.util.EmptyStackException (); 115 return stack.remove(stack.size()-1); 116 } 117 118 122 public int size() { 123 return stack.size(); 124 } 125 126 } | Popular Tags |