1
2
3
4
5
6
7 package net.sf.bddbddb.order;
8
9 import java.util.NoSuchElementException;
10 import java.util.Stack;
11
12
13 public class StackQueue extends Stack implements Queue{
14
15 /***
16 * Version ID for serialization.
17 */
18 private static final long serialVersionUID = 3257001047263425073L;
19
20
21
22
23 public boolean offer(Object arg0) {
24
25 push(arg0);
26 return true;
27 }
28
29
30
31
32 public Object poll() {
33 if(isEmpty()) return null;
34 return pop();
35 }
36
37
38
39
40 public Object remove() {
41 Object val = poll();
42 if(val == null) throw new NoSuchElementException();
43 return val;
44 }
45
46
47
48
49 public Object element() {
50 if(isEmpty()) throw new NoSuchElementException();
51
52 return peek();
53 }
54
55 }