<commit_before>package ru.pravvich.iterator_lessons.even_iterator;

import java.util.Iterator;

/**
 * Iterator which return only even numbers.
 * @param <T> any type which extends Number.
 */
public class EvenIterator<T extends Number> implements Iterator {
    /**
     * Array of values for processing.
     */
    private final T[] values;
    /**
     * Pointer on current cell in this.values.
     */
    private int index = 0;
    /**
     * Content only even numbers.
     * All work iterator is get from this.evenValues.
     */
    private T[] evenValues;

    /**
     * Default constructor.
     * @param values data for processing.
     */
    public EvenIterator(final T[] values) {
        this.values = values;
        initEvenValues();
    }

    /**
     * Init array to numbers which is even.
     * All work iterator is get from this.evenValues.
     */
    private void initEvenValues() {
        int lenEven = getLengthEvenValues();
        Number[] numbers = new Number[lenEven];
        try {
            evenValues = (T[]) numbers;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }

        for (int i = 0, j = 0; i < values.length && j < evenValues.length; i++) {
            if (isEven(values[i])) {
                evenValues[j] = values[i];
                j++;
            }
        }
    }


    /**
     * Exist in forward cell with even number.
     * @return if exist - true, if not exist - false.
     */
    @Override
    public boolean hasNext() {
        return index < evenValues.length;
    }

    /**
     * Moves forward point.
     * @return value which even.
     */<commit_msg>refactoring EvenIterator<commit_after>package ru.pravvich.iterator_lessons.even_iterator;

import java.util.Iterator;

/**
 * Iterator which return only even numbers.
 * @param <T> any type which extends Number.
 */
public class EvenIterator<T extends Number> implements Iterator {
    /**
     * Array of values for processing.
     */
    private final T[] values;
    /**
     * Pointer on current cell in this.values.
     */
    private int index = 0;
    /**
     * Content only even numbers.
     * All work iterator is get from this.evenValues.
     */
    private T[] evenValues;

    /**
     * Default constructor.
     * @param values data for processing.
     */
    public EvenIterator(final T[] values) {
        this.values = values;
        initEvenValues();
    }

    /**
     * Init array to numbers which is even.
     * All work iterator is get from this.evenValues.
     */
    private void initEvenValues() {
        try {
            evenValues = (T[]) new Number[getLengthEvenValues()];
        } catch (ClassCastException e) {
            e.printStackTrace();
        }

        for (int i = 0, j = 0; j < evenValues.length; i++) {
            if (isEven(values[i])) {
                evenValues[j++] = values[i];
            }
        }
    }


    /**
     * Exist in forward cell with even number.
     * @return if exist - true, if not exist - false.
     */
    @Override
    public boolean hasNext() {
        return index < evenValues.length;
    }

    /**
     * Moves forward point.
     * @return value which even.
     */
{'fraction_non_alphanumeric': 0.11162935323383084, 'fraction_numerical': 0.0018656716417910447, 'mean_word_length': 1.8570159857904085, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 7, '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': '1923049', 'n_tokens_mistral': 914, 'n_tokens_neox': 892, 'n_words': 288}