1 package jodd.util; 2 3 import java.util.LinkedList; 4 import java.util.NoSuchElementException; 5 6 9 public class SimpleStack { 10 11 private LinkedList list = new LinkedList(); 12 13 18 public void push(Object o) { 19 list.addLast(o); 20 } 21 22 27 public Object pop() { 28 Object result = null; 29 try { 30 result = list.removeLast(); 31 } catch (NoSuchElementException nsee) { 32 } 33 return result; 34 } 35 36 37 public Object[] popAll() { 38 Object[] res = list.toArray(); 39 list.clear(); 40 return res; 41 } 42 43 48 public Object peek() { 49 return list.getLast(); 50 } 51 52 53 58 public boolean isEmpty() { 59 return list.isEmpty(); 60 } 61 62 } 63 | Popular Tags |