<commit_before>package ru.job4j.generic;

/**
 * SimpleArray.
 * @param <T>
 *
 * @author Stanislav (<EMAIL>)
 * @since 12.09.2017
 */
public class SimpleArray<T> {
    /**
     */
    private Object[] array;
    /**
     */
    private int index = 0;

    /**
     * Constructor.
     * @param size - int
     */
    public SimpleArray(int size) {
        this.array = new Object[size];
    }

    /**
     * add.
     * @param v - T
     * @return return - boolean
     */
    public boolean add(T v) {
        boolean returnValue = true;

        if (this.index == this.array.length) {
            returnValue = false;
        } else {
            this.array[this.index++] = v;
        }

        return returnValue;
    }

    /**
     * update.
     * @param position - int
     * @param v - T
     * @return return - boolean
     */
    public boolean update(int position, T v) {
        boolean returnValue = true;

        if (position >= this.array.length) {
            returnValue = false;
        } else {
            this.array[position] = v;
        }

        return returnValue;
    }

    /**
     * delete.
     * @param position - int
     * @return return - boolean
     */
    public boolean delete(int position) {
        boolean returnValue = true;

        if (position >= this.array.length) {
            returnValue = false;
        } else {
            if (position == this.index - 1) {
                this.array[this.index--] = null;
            } else {
                this.array[position] = this.array[--this.index];
                this.array[this.index + 1] = null;
            }
        }

        return returnValue;
    }

    /**
     * delete.
     * @param v - T
     * @return return - boolean
     */
    public boolean delete(T v) {
        boolean returnValue = false;

        for (int i = 0; i < this.array.length; i++) {
            if (this.array[i] != null && this.array[i].equals(v)) {
                if (i == this.index - 1) {
                    this.array[this.index--] = null;
                } else {
                    this.array[i] = this.array[--this.index];
                    this.array[this.index] = null;
                }

                returnValue = true;
            }
        }

        return returnValue;
    }

    /**
     * get.
     * @param position - int
     * @return return - T
     */
    public T get(int position) {
        return position >= this.array.length ? null : (T) this.array[position];<commit_msg>task 156 fix and refactor<commit_after>package ru.job4j.generic;

/**
 * SimpleArray.
 * @param <T>
 *
 * @author Stanislav (<EMAIL>)
 * @since 12.09.2017
 */
public class SimpleArray<T> {
    /**
     */
    private Object[] array;
    /**
     */
    private int index = 0;

    /**
     * Constructor.
     * @param size - int
     */
    public SimpleArray(int size) {
        this.array = new Object[size];
    }

    /**
     * add.
     * @param v - T
     * @return return - boolean
     */
    public boolean add(T v) {
        boolean returnValue = true;

        if (this.index == this.array.length) {
            returnValue = false;
        } else {
            this.array[this.index++] = v;
        }

        return returnValue;
    }

    /**
     * update.
     * @param position - int
     * @param v - T
     * @return return - boolean
     */
    public boolean update(int position, T v) {
        boolean returnValue = true;

        if (position >= this.array.length) {
            returnValue = false;
        } else {
            this.array[position] = v;
        }

        return returnValue;
    }

    /**
     * delete.
     * @param position - int
     * @return return - boolean
     */
    public boolean delete(int position) {
        boolean returnValue = true;

        if (position >= this.array.length) {
            returnValue = false;
        } else {
            if (position == this.index - 1) {
                this.array[this.index--] = null;
            } else {
                this.array[position] = this.array[--this.index];
                this.array[this.index + 1] = null;
            }
        }

        return returnValue;
    }

    /**
     * delete.
     * @param v - T
     * @return return - boolean
     */
    public boolean delete(T v) {
        boolean returnValue = false;

        for (int i = 0; i < this.array.length; i++) {
            if (this.array[i] != null && this.array[i].equals(v)) {
                if (i == this.index - 1) {
                    this.array[this.index--] = null;
                } else {
                    this.array[i] = this.array[--this.index];
                    this.array[this.index] = null;
                }

                returnValue = true;
            }
        }

        return returnValue;
    }

    /**
     * get.
     * @param position - int
     * @return return - T
     */
    public T get(int position) {
        T returnValue;

        if (position < 0 || position >= this.array.length) {
            returnValue = null;
        } else {
            returnValue = (T) this.array[position];
        }

        return returnValue;
{'fraction_non_alphanumeric': 0.13032483952538418, 'fraction_numerical': 0.0062244699474810344, 'mean_word_length': 1.303763440860215, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 15, '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': '7057270', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1487, 'n_words': 360}