View Javadoc

1   package ca.uhn.hl7v2.testpanel.util;
2   
3   import java.util.LinkedList;
4   
5   public class LimitedQueue<E> extends LinkedList<E> {
6   
7       private int limit;
8   
9       public LimitedQueue(int limit) {
10          this.limit = limit;
11      }
12  
13      @Override
14      public boolean add(E o) {
15          super.add(o);
16          while (size() > limit) { super.remove(); }
17          return true;
18      }
19      
20  }