import java.util.Iterator; import java.util.NoSuchElementException; /**Realization of a set by means of an array, which is doubled *when the size of the set exceeds the capacity of the array */ public class ArraySet1 implements Set { private E[] A; //array storing the elements of the set private int capacity=16; //initial length of array A private int size=0; //number of elements stored in the list /**Creates the list with initial capacity 16. */ public ArraySet1(){ A= (E[]) new Object[capacity];//Compiler may warn, but ok } public int size() { return size; } /**Adds the specified element to this set if not already present */ public boolean add(E e) { boolean toAdd=false; if (!contains(e)){ toAdd=true; if(size==capacity){ capacity *=2; E[] B=(E[]) new Object[capacity]; for (int i=0;i iterator() {ArraySetIterator tempIterator=new ArraySetIterator(); return (Iterator) tempIterator;} private class ArraySetIterator implements Iterator{ private int current=0; /**Returns true if the iteration has more elements*/ public boolean hasNext() {return current