View Javadoc

1   /*
2    * Created on Mar 2, 2005
3    *
4    * TODO To change the template for this generated file go to
5    * Window - Preferences - Java - Code Style - Code Templates
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      /* (non-Javadoc)
21       * @see java.util.Queue#offer(java.lang.Object)
22       */
23      public boolean offer(Object arg0) {
24          // TODO Auto-generated method stub
25          push(arg0);
26          return true;
27      }
28  
29      /* (non-Javadoc)
30       * @see java.util.Queue#poll()
31       */
32      public Object poll() {
33          if(isEmpty()) return null;
34          return pop();
35      }
36  
37      /* (non-Javadoc)
38       * @see java.util.Queue#remove()
39       */
40      public Object remove() {
41          Object val = poll();
42          if(val == null) throw new NoSuchElementException();
43          return val;
44      }
45  
46      /* (non-Javadoc)
47       * @see java.util.Queue#element()
48       */
49      public Object element() {
50          if(isEmpty()) throw new NoSuchElementException();
51          
52          return peek();
53      }
54  
55  }