<commit_before>package ru.job4j.iterator;

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

public class EvenNumbersIterator implements Iterator<Integer>{
    final int[] numbers;
    int index = 0;

    public EvenNumbersIterator(int[] numbers) {
        this.numbers = numbers;
    }

    @Override
    public boolean hasNext() {
        int count = 0;
        boolean result = false;
        if (index >= numbers.length) {
            result = false;
        }
        for (int i = index; i < numbers.length; i++) {
            if (numbers[i] % 2 == 0) {
                ++count;
            }
        }
        if (count >= 1) {
            result = true;
        }
        return result;
    }

    @Override
    public Integer next() {
        int element = 0;
        if (hasNext()) {
            if (numbers[index] % 2 == 0) {
                element = numbers[index++];
            }
            else {
                for (int i = index; i < numbers.length; i++) {
                    if (numbers[i] % 2 == 0) {
                        index = i;
                        break;
                    }
                }
                element = numbers[index++];
            }
        }
        else {
            throw new NoSuchElementException();
        }
        return element;
       /* System.out.println(index);
        for (int i = index; i < numbers.length; i++) {
            if (numbers[i] % 2 == 0) {
               index = i;
               break;
            }
        }
        if (numbers[index] %  2 != 0) {
            throw new NoSuchElementException();
        }
        return numbers[index++];*/
    }
}<commit_msg>iterator для четных чисел пыталась без повторений проверки<commit_after>package ru.job4j.iterator;

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

public class EvenNumbersIterator implements Iterator<Integer>{
    final int[] numbers;
    int index = 0;

    public EvenNumbersIterator(int[] numbers) {
        this.numbers = numbers;
    }

    @Override
    public boolean hasNext() {
        int count = 0;
        boolean result = false;
        if (index >= numbers.length) {
            result = false;
        }
        for (int i = index; i < numbers.length; i++) {
            if (numbers[i] % 2 == 0) {
                ++count;
            }
        }
        if (count >= 1) {
            result = true;
        }
        return result;
    }

    @Override
    public Integer next() {
        int element = 0;
        if (hasNext()) {
            for (int i = index; i < numbers.length; i++) {
                if (numbers[i] % 2 == 0) {
                    index = i;
                    break;
                }
            }
            element = numbers[index++];
        }
        else {
            throw new NoSuchElementException();
        }
        return element;
    }
}
{'fraction_non_alphanumeric': 0.11168921262573708, 'fraction_numerical': 0.008324661810613945, 'mean_word_length': 1.2870737509912769, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, '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': '3403367', 'n_tokens_mistral': 830, 'n_tokens_neox': 779, 'n_words': 212}