01: /*
02: * Created on 02-Feb-2006
03: *
04: * TODO To change the template for this generated file go to
05: * Window - Preferences - Java - Code Style - Code Templates
06: */
07: package com.jofti.util;
08:
09: import java.util.Collection;
10: import java.util.Iterator;
11: import java.util.LinkedList;
12:
13: /**
14: * @author xenephon
15: */
16: public class FastStack {
17:
18: /**
19: *
20: */
21: LinkedList list = new LinkedList();
22:
23: public FastStack() {
24: super ();
25: // TODO Auto-generated constructor stub
26: }
27:
28: public Object pop() {
29:
30: return list.removeLast();
31: }
32:
33: public Object peek() {
34:
35: return list.getLast();
36: }
37:
38: public int size() {
39: return list.size();
40: }
41:
42: public void push(Object obj) {
43: list.add(obj);
44: }
45:
46: public synchronized boolean addAll(Collection c) {
47: Iterator it = c.iterator();
48:
49: int size = c.size();
50:
51: for (int i = 0; i < size; i++) {
52: list.add(it.next());
53: }
54: return true;
55: }
56: }
|