1 19 20 package gnu.trove; 21 22 30 31 public class TIntStack { 32 33 34 protected TIntArrayList _list; 35 36 public static final int DEFAULT_CAPACITY = TIntArrayList.DEFAULT_CAPACITY; 37 38 42 public TIntStack() { 43 this(DEFAULT_CAPACITY); 44 } 45 46 52 public TIntStack(int capacity) { 53 _list = new TIntArrayList(capacity); 54 } 55 56 61 public void push(int val) { 62 _list.add(val); 63 } 64 65 70 public int pop() { 71 return _list.remove(_list.size() - 1); 72 } 73 74 79 public int peek() { 80 return _list.get(_list.size() - 1); 81 } 82 83 88 public int size() { 89 return _list.size(); 90 } 91 92 95 public void clear() { 96 _list.clear(DEFAULT_CAPACITY); 97 } 98 99 102 public void reset() { 103 _list.reset(); 104 } 105 } | Popular Tags |