<commit_before>package ru.job4j.service;

public class LinkedNode<T> {
    Node<T> first;

    public Node<T> linked() {
         this.first = new Node(1);
        Node two = new Node(2);
        Node third = new Node(3);
        Node four = new Node(4);

        this.first.next = two;
        two.next = third;
        third.next = four;
        four.next = first;

        return first;
    }

    boolean hasCycle(Node first) {
        boolean result = false;
        Node<T> check = first;
       Node<T> current = first;
        while (current.next != null) {
            check = current;
           while (current.next != null) {
               if (current.next == check) {
                   result = true;
                   break;
               }
               current = current.next;
           }
            //во внешнем же цикле значение current не меняется?
           current = check; //на случай, если меняется из-за внутреннего цикла
            current = current.next;
        }
        return result;

    }

}
<commit_msg>алгоритм на зацикленность списка без 2й переменной<commit_after>package ru.job4j.service;

public class LinkedNode<T> {
    Node<T> first;

    public Node<T> linked() {
         this.first = new Node(1);
        Node two = new Node(2);
        Node third = new Node(3);
        Node four = new Node(4);

        this.first.next = two;
        two.next = third;
        third.next = four;
        four.next = first;

        return first;
    }

    boolean hasCycle(Node first) {
        boolean result = false;

        Node<T> check = first;
       Node<T> current = first;

       while (current.next != null) {
            check = current;

           while (current.next != null) {
               if (current.next == check) {
                   result = true;
                   break;
               }
               current = current.next;
           }
            //во внешнем же цикле значение current не меняется?

           current = check; //на случай, если меняется из-за внутреннего цикла
            current = current.next;
        }
        return result;

    }
    boolean hasCycle2(Node first) {
        boolean result = false;
        Node<T> current = first;

        while (current.next != null) {
            while (current.next != null) {
                if (current.next == current) {
                    result = true;
                    break;
                }
                current.next = current.next.next;
            }
            current = current.next;
        }
        return result;
    }

}

{'fraction_non_alphanumeric': 0.09891388673390225, 'fraction_numerical': 0.004654771140418929, 'mean_word_length': 1.3509571558796718, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '675121', 'n_tokens_mistral': 752, 'n_tokens_neox': 750, 'n_words': 201}