@@ -0,0 +1,2447 @@
+/**%0A * %0A */%0Apackage utils.collections;%0A%0Aimport java.util.ArrayDeque;%0A%0A/**%0A * @author Jenna Sloan%0A *%0A */%0Apublic class LimitedSizeDeque%3CE%3E extends ArrayDeque%3CE%3E%0A%7B%0A%09private int capacity;%0A%09public LimitedSizeDeque(int capacity)%7B%0A%09%09super(capacity);%0A%09%7D%0A%09/**%0A%09 * Inserts the specified element at the end of this deque, removing%0A%09 * the element at the beginning of this deque if at capacity.%0A%09 *%0A%09 * %3Cp%3EThis method is equivalent to %7B@link #addLast%7D.%0A%09 *%0A%09 * @param e the element to add%0A%09 * @return true%0A%09 * @throws NullPointerException if the specified element is null%0A%09 */%0A%09public boolean add(E e)%7B%0A%09%09addLast(e);%0A%09%09return true;%0A%09%7D%0A%09/**%0A%09 * Inserts the specified element at the end of this deque, removing%0A%09 * the element at the beginning of this deque if at capacity.%0A%09 *%0A%09 * %3Cp%3EThis method is equivalent to %7B@link #offerLast%7D.%0A%09 *%0A%09 * @param e the element to add%0A%09 * @return true%0A%09 * @throws NullPointerException if the specified element is null%0A%09 */%0A%09public boolean offer(E e)%7B%0A%09%09addLast(e);%0A%09%09return true;%0A%09%7D%0A%09/**%0A%09 * Inserts the specified element at the front of this deque, removing%0A%09 * the element at the end of this deque if at capacity.%0A%09 *%0A%09 * @param e the element to add%0A%09 * @throws NullPointerException if the specified element is null%0A%09 */%0A%09public void addFirst(E e)%7B%0A%09%09if(size()%3E=capacity)%0A%09%09%09removeLast();%0A%09%09super.addFirst(e);%0A%09%7D%0A%09/**%0A%09 * Inserts the specified element at the end of this deque, removing%0A%09 * the element at the beginning of this deque if at capacity.%0A%09 *%0A%09 * %3Cp%3EThis method is equivalent to %7B@link #add%7D.%0A%09 *%0A%09 * @param e the element to add%0A%09 * @throws NullPointerException if the specified element is null%0A%09 */%0A%09public void addLast(E e)%7B%0A%09%09if(size()%3E=capacity)%0A%09%09%09removeFirst();%0A%09%09super.addLast(e);%0A%09%7D%0A%09/**%0A%09 * Inserts the specified element at the front of this deque, removing%0A%09 * the element at the end of this deque if at capacity.%0A%09 *%0A%09 * @param e the element to add%0A%09 * @return true%0A%09 * @throws NullPointerException if the specified element is null%0A%09 */%0A%09public boolean offerFirst(E e)%7B%0A%09%09addFirst(e);%0A%09%09return true;%0A%09%7D%0A%09/**%0A%09 * Inserts the specified element at the end of this deque, removing%0A%09 * the element at the beginning of this deque if at capacity.%0A%09 *%0A%09 * @param e the element to add%0A%09 * @return true%0A%09 * @throws NullPointerException if the specified element is null%0A%09 */%0A%09public boolean offerLast(E e)%7B%0A%09%09addLast(e);%0A%09%09return true;%0A%09%7D%0A%09/**%0A%09 * %7B@inheritDoc%7D%0A%09 */%0A%09public void push(E e)%7B%0A%09%09addFirst(e);%0A%09%7D%0A%09%0A%7D%0A

Create LimitedSizeDeque.java