<commit_before>package ru.job4j.set;

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

public class SimpleSetBasedLinkedList<T> implements Iterable<T> {

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

    //Add unique element
    public boolean add(T value) {
        //Checking duplicate
        Node<T> node = first;
        if (node != null) {
            for (int i = 0; i < size; i++) {
                Node<T> tmp = node;
                if (node.item.equals(value)) {
                    return false;
                }
               node = tmp.next;
            }
        }
        // Add element
        Node<T> tmp = last;
        Node<T> newNode = new Node<>(value, null);
        last = newNode;

        if (first == null) {
            first = newNode;
        } else {
            tmp.next = newNode;
        }
        size++;
        return true;
    }<commit_msg>2. Set реализованный на связном списке (1)<commit_after>package ru.job4j.set;

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

public class SimpleSetBasedLinkedList<T> implements Iterable<T> {

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

    //if duplicate return true else false
    private boolean isDuplicate(T value) {
        Node<T> node = first;
        if (node != null) {
            for (int i = 0; i < size; i++) {
                Node<T> tmp = node;
                if (node.item.equals(value)) {
                    return true;
                }
                node = tmp.next;
            }
        }
        return false;
    }

    //Add unique element
    public boolean add(T value) {

        //Checking duplicate
        if (isDuplicate(value)) {
            return false;
        }

        // Add element
        Node<T> tmp = last;
        Node<T> newNode = new Node<>(value, null);
        last = newNode;

        if (first == null) {
            first = newNode;
        } else {
            tmp.next = newNode;
        }
        size++;
        return true;
    }
{'fraction_non_alphanumeric': 0.10705712914066251, 'fraction_numerical': 0.003840614498319731, 'mean_word_length': 1.4691943127962086, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, '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': '3751282', 'n_tokens_mistral': 622, 'n_tokens_neox': 603, 'n_words': 172}