package ru.matevosyan;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * CycleDetection class.
 * Created on 26.05.2017.
 * @author Matevosyan Vardan
 * @version 1.0
 */

public class CycleDetection<E>{

    private Node<E> last;
    private int size = 0;
    private Node<E> first;

    /**
     * Constructor.
     */

    public CycleDetection() {

    }


    /**
     * Class Node describe linkedList entry.
     * @param <E> parameter that defined when create an instance of a class.
     */

    private static class Node<E> {
        E item;
        Node<E> next;

        Node(E element, Node<E> next) {
            this.item = element;
            this.next = next;
        }
    }

}
@@ -221,16 +221,17 @@
 ction%3CE%3E
+ 
 %7B%0A%0A    p
@@ -241,75 +241,277 @@
 ate 
-Node%3CE%3E last;%0A    private int size = 0;%0A    private Node%3CE%3E
+int size = 0;%0A%0A%0A    /**%0A     * Constructor.%0A     */%0A%0A    public CycleDetection() %7B%0A    %7D%0A%0A    boolean hasCycle(Node%3CE%3E first) %7B%0A        Node%3CE%3E fast;%0A        Node%3CE%3E slow;%0A        boolean detForFastToSlow = true;%0A%0A        if (first != null) %7B%0A            fast =
  first;%0A
 %0A   
@@ -510,84 +510,493 @@
 st;%0A
-%0A
     
-/**%0A
+   
      
-* Constructor.%0A
+slow = first;%0A        %7D else %7B%0A            return false;%0A 
      
-*/
+  %7D
 %0A%0A    
-public CycleDetection() %7B%0A%0A    %7D%0A%0A
+    while (fast != null) %7B%0A            if (detForFastToSlow) %7B%0A                fast = fast.next.next;%0A            %7D else %7B%0A                fast = fast.next;%0A            %7D%0A%0A            if (fast == slow.next) %7B%0A                detForFastToSlow = false;%0A                if (fast == slow) %7B%0A                    slow = first;%0A                %7D%0A            %7D%0A        %7D%0A        return detForFastToSlow;%0A    %7D
 %0A   

add one method