package ru.aserdyuchenko.list.task_5_3_4;

import java.util.LinkedList;
import java.util.List;

/**
 * @author anton.
 * @param <T> - T.
 */
public class Node<T> {
    /**
     * @param value - value.
     */
    private T value;
    /**
     * @param next - next.
     */
    private Node<T> next;

    /**
     * Constructor.
     * @param t - new value.
     */
    Node(T t) {
        this.next = null;
        this.value = t;
    }

    /**
     * Get next.
     * @return - next.
     */
    public Node getNext()  {
        return this.next;
    }

    /**
     * Set next.
     * @param nextValue - next value.
     */
    public void setNext(Node<T> nextValue) {
        this.next = nextValue;
    }

    /**
     * Has cycle.
     * @param first - first node.
     * @return true or false.
     */
    boolean hasCycle(Node first) {
        List<Node> list = new LinkedList<>();
        Node newNode = first;
        while (newNode != null) {
            if (list.contains(newNode)) {
                return true;
            } else {
                list.add(newNode);
                newNode = newNode.getNext();
            }
        }
        return false;
    }

}
@@ -840,54 +840,8 @@
 ) %7B%0A
-        List%3CNode%3E list = new LinkedList%3C%3E();%0A
     
@@ -864,16 +864,26 @@
  = first
+.getNext()
 ;%0A      
@@ -930,20 +930,19 @@
 if (
-list.contain
+first.equal
 s(ne
@@ -1005,43 +1005,8 @@
 e %7B%0A
-                list.add(newNode);%0A
     
@@ -1098,10 +1098,9 @@
 ;%0A    %7D%0A
-%0A
 %7D

Edit task (RCheck node cykle) #161.