@@ -0,0 +1,3204 @@
+package ru.matevosyan;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Iterator;%0A%0A/**%0A *  DynamicSimpleSet class.%0A * Created on 27.05.2017.%0A * @author Matevosyan Vardan%0A * @version 1.0%0A */%0A%0Apublic class  DynamicSimpleSet%3CE%3E implements IDynamicSimpleSet%3CE%3E,  Iterable%3CE%3E%7B%0A%0A    private Object%5B%5D container;%0A    private static final int DEFAULTARRAYSIZE = 10;%0A    private int index = 0;%0A%0A    /**%0A     * If arrays size was not passed to constructor, create an array with default size.%0A     */%0A%0A    public DynamicSimpleSet() %7B%0A        this.container = new Object%5BDEFAULTARRAYSIZE%5D;%0A    %7D%0A%0A    /**%0A     * Create to add value to an array.%0A     * @param value is value that type which you declare in generics.%0A     * @throws ArrayIndexOutOfBoundsException if index is bigger than actual.%0A     */%0A%0A    @Override%0A    public void add(E value) throws ArrayIndexOutOfBoundsException %7B%0A        checkSize(this.index + 1);%0A        boolean theSame = true;%0A%0A        for(Object o : this.container) %7B%0A            if ((value.equals(o))) %7B%0A                theSame = false;%0A            %7D%0A        %7D%0A%0A        if (theSame) %7B%0A            this.container%5Bthis.index++%5D = value;%0A        %7D%0A    %7D%0A%0A%0A    /**%0A     * Check array size and rise it when an array length is equal or bigger that default size.%0A     * Or if it is the last index that going to be hold by passing value.%0A     * @param nextIndex is next index that going to be checked.%0A     */%0A%0A    private void checkSize(int nextIndex) %7B%0A        if (this.container.length - 1 == nextIndex && this.container.length %3E= DEFAULTARRAYSIZE) %7B%0A            int nexSize = (this.container.length * 3) / 2 + 1;%0A            this.container = Arrays.copyOf(this.container, nexSize);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Create to get the value from an array.%0A     * @param index position value in an array.%0A     * @return value that type that was declare in generic diamonds.%0A     * @throws IllegalArgumentException if is not correct index size.%0A     * @throws ArrayIndexOutOfBoundsException if index is bigger than actual.%0A     */%0A%0A    @Override%0A    @SuppressWarnings(%22unchecked%22)%0A    public E get(int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException %7B%0A        if (index %3E= this.index) %7B%0A            throw new ArrayIndexOutOfBoundsException(%22index id out of bounds%22);%0A        %7D else if (index %3C 0 && ((Integer) index instanceof Number))%7B%0A           throw new IllegalArgumentException(%22illegal argument%22);%0A        %7D else %7B%0A            return  (E) this.container%5Bindex%5D;%0A        %7D%0A    %7D%0A%0A    /**%0A     * Size of an array.%0A     * @return set size.%0A     */%0A%0A    @Override%0A    public int length() %7B%0A        return index;%0A    %7D%0A%0A    /**%0A     * Override iterator method from interface Iterable.%0A     * @return an instance of Iterator type.%0A     */%0A%0A    @Override%0A    public Iterator%3CE%3E iterator() %7B%0A%0A        return new Iterator%3CE%3E() %7B%0A%0A            int count = 0;%0A            @Override%0A            public boolean hasNext() %7B%0A                return count %3C container.length - (container.length - index);%0A            %7D%0A%0A            @Override%0A            @SuppressWarnings(%22unchecked%22)%0A            public E next() %7B%0A                return (E) container%5Bcount++%5D;%0A            %7D%0A        %7D;%0A    %7D%0A%7D

add DynamicSimpleSet.java