package ru.job4j.pro.list;

/**
 * This class describes collection queue.
 *
 * @param <E> is generic type
 */
public class Queue<E> {

    /**
     * parameter first is link to first element of the queue.
     */
    private Node<E> first;
    /**
     * parameter last is link to last element of the queue.
     */
    private Node<E> last;

    /**
     * method add element to the and of collection.
     *
     * @param element is input element
     * @return true
     */
    public boolean push(E element) {

        Node<E> newNode = new Node<>();

        newNode.value = element;

        if (first == null) {
            first = newNode;
            last = newNode;
        } else {
            last.next = newNode;
            last = newNode;
        }

        return true;

    }

    /**
     * method delete last element and return value.
     *
     * @return value of last element
     */
    public E pop() {

        E result = first.value;

        first = first.next;

        return result;

    }

    /**
     * method return true if collection have no elements.
     *
     * @return true if collection is empty
     */
    public boolean isEmpty() {
        return first == null;
    }

    /**
     * inner class describes node of collection queue.
     *
     * @param <E> is generic type
     */
    private class Node<E> {

        /**
         * parameter next is link to next element of list.
         */
        private Node<E> next;
        /**
         * parameter value is value of node.
         */
        private E value;

    }

}

@@ -21,16 +21,44 @@
 .list;%0A%0A
+import java.util.Iterator;%0A%0A
 /**%0A * T
@@ -149,24 +149,47 @@
 ass Queue%3CE%3E
+ implements Iterable%3CE%3E
  %7B%0A%0A    /**%0A
@@ -1018,26 +1018,121 @@
     
-first = first.next
+Node%3CE%3E current = first;%0A%0A        first = first.next;%0A%0A        current.next = null;%0A%0A        current.value = null
 ;%0A%0A 
@@ -1345,32 +1345,215 @@
 == null;%0A    %7D%0A%0A
+    /**%0A     * method return queue iterator.%0A     *%0A     * @return queue iterator%0A     */%0A    @Override%0A    public Iterator%3CE%3E iterator() %7B%0A        return new QueueIterator();%0A    %7D%0A%0A
     /**%0A     * i
@@ -1892,10 +1892,561 @@
 %0A    %7D%0A%0A
+    /**%0A     * This inner class describes queue iterator.%0A     */%0A    private class QueueIterator implements Iterator%3CE%3E %7B%0A%0A        /**%0A         * method return true if queue have elements.%0A         *%0A         * @return true if queue have elements%0A         */%0A        @Override%0A        public boolean hasNext() %7B%0A            return !isEmpty();%0A        %7D%0A%0A        /**%0A         * method return first element.%0A         *%0A         * @return first element%0A         */%0A        @Override%0A        public E next() %7B%0A            return pop();%0A        %7D%0A%0A    %7D%0A%0A
 %7D%0A

Refactor Queue.java add code to null of pop node