@@ -0,0 +1,2283 @@
+package me.alivecode.algs4;%0A%0Aimport java.util.Iterator;%0Aimport java.util.NoSuchElementException;%0A%0Aimport edu.princeton.cs.algs4.StdIn;%0Aimport edu.princeton.cs.algs4.StdOut;%0A%0Apublic class Queue%3CItem%3E implements Iterable%3CItem%3E %7B%0A    private Node first;%0A    private Node last;%0A    private int size;%0A%0A    private class Node %7B%0A        Item item;%0A        Node next;%0A    %7D%0A%0A    public Queue() %7B%0A        first = null;%0A        last = null;%0A        size = 0;%0A    %7D%0A%0A    public boolean isEmpty() %7B return first == null; %7D%0A%0A    public int size() %7B return size; %7D%0A%0A    public Item peek() %7B%0A        if (isEmpty()) %7B throw new NoSuchElementException(%22Empty queue%22); %7D%0A        return first.item;%0A    %7D%0A%0A    public void enqueue(Item item) %7B%0A        Node oldLast = last;%0A        last = new Node();%0A        last.item = item;%0A        last.next = null;%0A        if (isEmpty()) %7B%0A            first = last;%0A        %7D%0A        else %7B%0A            oldLast.next = last;%0A        %7D%0A        size++;%0A    %7D%0A%0A    public Item dequeue() %7B%0A        if (isEmpty()) %7B throw new NoSuchElementException(%22Empty queue%22); %7D%0A        Item item = first.item;%0A        first = first.next;%0A        if (isEmpty()) %7B%0A            last = null;%0A        %7D%0A        size--;%0A        return item;%0A    %7D%0A%0A    public Iterator%3CItem%3E iterator() %7B return new ListIterator(); %7D%0A%0A    private class ListIterator implements Iterator%3CItem%3E %7B%0A        private Node current = first;%0A%0A        public boolean hasNext() %7B return current != null; %7D%0A%0A        public void remove() %7B throw new UnsupportedOperationException(); %7D%0A%0A        public Item next() %7B%0A            if (!hasNext()) %7B throw new NoSuchElementException(%22Empty Queue%22); %7D%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%0A        Queue%3CString%3E queue = new Queue%3CString%3E();%0A%0A        while (!StdIn.isEmpty()) %7B%0A            String item = StdIn.readString();%0A            if (!item.equals(%22-%22)) %7B%0A                queue.enqueue(item);%0A            %7D%0A            else %7B%0A                StdOut.println(queue.dequeue());%0A            %7D%0A        %7D%0A        StdOut.println(queue.size() + %22 item(s) in the queue.%22);%0A        for(String item: queue) %7B%0A            StdOut.println(item);%0A        %7D%0A    %7D%0A%7D%0A

Add Queue class.