<commit_before>package ru.ematveev.generic;

/**
 * Class for storages the different elements.
 * @param <T> parametrized type.
 */
public class SimpleArray<T> {
    private Object[] objects;
    private int index = 0;

    /**
     * Method for initializing an array.
     * @param size array size.
     */
    public SimpleArray(int size) {
        this.objects = new Object[size];
    }

    /**
     * Array Objects for storing different types of elements.
     * @return array.
     */

    public Object[] getObjects() {
        return objects;
    }
    /**
     * Method adds the elements to an array.
     * @param value Incoming element of any type.
     */
    public void add(T value) {
        this.objects[index++] = value;
    }

    /**
     * Getting an item by index.
     * @param position number of the cell in the array where the element is located.
     * @return the element of type T.
     */
    public T getValue(int position) {
        return (T) this.objects[position];
    }

    /**
     * Method for changing the value of an element in an array.
     * @param position number of the cell in the array where the element is located.
     * @param value value of an element in an array of type T.
     */
    public void update(int position, T value) {
        this.objects[position] = value;
    }

    /**
     * A method that returns the position of an element in an array cell by the value of the element.
     * @param value value of an element in an array of type T.
     * @return number of the cell in the array where the element is located.
     */
    public int getIndex(T value) {
        int result = -1;
        for (int i = 0; i < this.objects.length; i++) {
            if (objects[i].equals(value)) {
                result = i;
            }
        }
        return result;
    }
}
<commit_msg>SimpleArray - change methods add() and update()<commit_after>package ru.ematveev.generic;

import java.util.Arrays;

/**
 * Class for storages the different elements.
 * @param <T> parametrized type.
 */
public class SimpleArray<T> {
    private Object[] objects;
    private int index = 0;

    /**
     * Method for initializing an array.
     * @param size array size.
     */
    public SimpleArray(int size) {
        this.objects = new Object[size];
    }

    /**
     * Array Objects for storing different types of elements.
     * @return array.
     */

    public Object[] getObjects() {
        return objects;
    }
    /**
     * Method adds the elements to an array.
     * @param value Incoming element of any type.
     */
    public void add(T value) {
        if(index < objects.length) {
            this.objects[index++] = value;
        } else {
            objects = Arrays.copyOf(objects, objects.length * 2);
            this.objects[index++] = value;
        }
    }

    /**
     * Getting an item by index.
     * @param position number of the cell in the array where the element is located.
     * @return the element of type T.
     */
    public T getValue(int position) {
        return (T) this.objects[position];
    }

    /**
     * Method for changing the value of an element in an array.
     * @param position number of the cell in the array where the element is located.
     * @param value value of an element in an array of type T.
     */
    public void update(T valueOld, T valueNew) {
        for (Object elem: this.objects) {
            if(elem.equals(valueOld)) {
                valueOld = valueNew;
            }
        }
    }

    /**
     * A method that returns the position of an element in an array cell by the value of the element.
     * @param value value of an element in an array of type T.
     * @return number of the cell in the array where the element is located.
     */
    public int getIndex(T value) {
        int result = -1;
        for (int i = 0; i < this.objects.length; i++) {
            if (objects[i].equals(value)) {
                result = i;
            }
        }
        return result;
    }
}

{'fraction_non_alphanumeric': 0.0966940094456873, 'fraction_numerical': 0.0017399950285856326, 'mean_word_length': 1.9159420289855071, 'pattern_counts': {'":': 0, '<': 10, '<?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': '4668772', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1108, 'n_words': 447}