package ru.job4j.collection.list;

import java.util.Arrays;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NoSuchElementException;

public class DinamicArrayConteiner<E> implements Iterable<E> {

    int lengthcIndex = 20;
    Object[] container = new Object[lengthcIndex];
    int indexFull = 2;
    int size = 0;
    int indexRiseArray = 2;
    int modCount = 0;

    public void add(E value) {
        this.container[size++] = value;
        modCount++;
        if (container.length - size < indexFull) {
            this.container = Arrays.copyOf(container, lengthcIndex * indexRiseArray);
        }
    }

    public E get(int index) {
        E value = (E) this.container[index];
        return value;
    }

    @Override
    public Iterator<E> iterator() {

        return new Iterator<E>() {
            int indexI;
            int expectedModcount = modCount;

            @Override
            public boolean hasNext() {
                return indexI < size;
            }

            @Override
            public E next() {
                if (expectedModcount != modCount) {
                    throw new ConcurrentModificationException();
                }
                if (!hasNext()) {
                    throw new NoSuchElementException();
                }
                return (E) container[indexI++];
            }
        };
    }
}

@@ -171,17 +171,115 @@
 eption;%0A
+/**%0A * %D0%94%D0%B8%D0%BD%D0%B0%D0%BC%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D0%B9 %D1%81%D0%BF%D0%B8%D1%81%D0%BE%D0%BA %D0%BD%D0%B0 %D0%B1%D0%B0%D0%B7%D0%B5 %D0%BC%D0%B0%D1%81%D1%81%D0%B8%D0%B2%D0%B0%0A *%0A * %22param %3CE%3E %D0%A2%D0%B8%D0%BF %D1%8D%D0%BB%D0%B5%D0%BC%D0%B5%D0%BD%D1%82%D0%B0 %D0%B4%D0%B8%D0%BD%D0%B0%D0%BC%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%BE%D0%B3%D0%BE %D0%BC%D0%B0%D1%81%D1%81%D0%B8%D0%B2%D0%B0%0A */
 %0A
-
 public c
@@ -330,24 +330,47 @@
 rable%3CE%3E %7B%0A%0A
+    /**%0A     *%0A     */%0A
     int leng
@@ -755,16 +755,66 @@
 Array);%0A
+            this.lengthcIndex = container.length;%0A
         
@@ -922,24 +922,202 @@
 lue;%0A    %7D%0A%0A
+    public void set(int position, E model) %7B%0A        this.container%5Bposition%5D = model;%0A    %7D%0A%0A    public void delete(int index) %7B%0A        this.container%5Bindex--%5D = null;%0A%0A    %7D%0A%0A
     @Overrid
@@ -1723,32 +1723,32 @@
 ;%0A            %7D%0A
-
         %7D;%0A    %7D
@@ -1747,11 +1747,276 @@
 %7D;%0A    %7D
+%0A%0A    public int getLengthcIndex() %7B%0A        return lengthcIndex;%0A    %7D%0A%0A    public int getSize() %7B%0A        return size;%0A    %7D%0A%0A    public Object%5B%5D getContainer() %7B%0A        return container;%0A    %7D%0A%0A    public void setSize(int size) %7B%0A        this.size = size;%0A    %7D
 %0A%7D%0A

Change DinamicArryayContainer with my comp at my home