@@ -0,0 +1,2154 @@
+import java.util.Iterator;%0Aimport java.util.NoSuchElementException;%0A%0A%0Apublic class Deque%3CItem%3E implements Iterable%3CItem%3E %7B%0A%0A    private Node first, last;%0A    private int size;%0A%0A    private class Node %7B%0A        Item item;%0A        Node next;%0A        Node previous;%0A    %7D%0A%0A    public Deque() %7B%0A        size = 0;%0A        first = null;%0A        last = null;%0A    %7D%0A%0A    public boolean isEmpty() %7B%0A        return first == null;%0A    %7D%0A%0A    public int size() %7B%0A        return size;%0A    %7D%0A%0A    public void addFirst(Item item) %7B%0A        if (item == null) throw new IllegalArgumentException();%0A%0A        Node oldfirst = first;%0A        first = new Node();%0A        first.item = item;%0A        first.next = oldfirst;%0A        first.previous = null;%0A%0A        if (oldfirst == null) last = first;%0A%0A        size++;%0A    %7D%0A%0A    public void addLast(Item item) %7B%0A        if (item == null) throw new IllegalArgumentException();%0A%0A        Node oldlast = last;%0A        last = new Node();%0A        last.item = item;%0A        last.next = null;%0A        last.previous = oldlast;%0A%0A        if (oldlast == null) first = last;%0A        else oldlast.next = last;%0A%0A        size++;%0A    %7D%0A%0A    public Item removeFirst() %7B%0A        if (isEmpty()) throw new NoSuchElementException();%0A        Item item = first.item;%0A        first = first.next;%0A        size --;%0A%0A        return item;%0A    %7D%0A%0A    public Item removeLast() %7B%0A        if (isEmpty()) throw new NoSuchElementException();%0A        Item item = last.item;%0A        last = last.previous;%0A        size--;%0A%0A        return item;%0A    %7D%0A%0A    public Iterator%3CItem%3E iterator() %7B%0A        return new DequeIterator();%0A    %7D%0A%0A    private class DequeIterator implements Iterator%3CItem%3E %7B%0A%0A        private Node current = first;%0A%0A        public boolean hasNext() %7B%0A            return current != last;%0A        %7D%0A%0A        public void remove() %7B%0A            throw new UnsupportedOperationException();%0A        %7D%0A%0A        public Item next() %7B%0A            if (isEmpty()) throw new NoSuchElementException();%0A%0A            Item item = current.item;%0A            current = current.next;%0A            return item;%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%7D%0A%7D

Create Deque