package sophomore.classfile;

import java.util.Iterator;
import java.util.NoSuchElementException;

abstract class Members <T> implements Iterable<T> {
	
	T[] elements;
	int currentIndex = 0;

	public Members() {}

	public int getSize() {
		return elements.length;
	}

	public void addElement(T element) {
		if(currentIndex == elements.length) {
			throw new ArrayIndexOutOfBoundsException();
		}
		elements[currentIndex++] = element;
	}

	@Override
	public Iterator<T> iterator() {
		return new Iterator<T>() {
			private int index = 0;
			@Override
			public boolean hasNext() {
				return index < elements.length;
			}

			@Override
			public T next() {
				if(hasNext()) {
					return elements[index++];
				}
				throw new NoSuchElementException("" + index);
			}
		};
	}
	
}
@@ -122,34 +122,11 @@
  %3CT%3E
- implements Iterable%3CT%3E
  %7B%0A
+
 %09%0A%09T
@@ -413,344 +413,55 @@
 %7D%0A%0A%09
-@Override%0A%09public Iterator%3CT%3E iterator() %7B%0A%09%09return new Iterator%3CT%3E() %7B%0A%09%09%09private int index = 0;%0A%09%09%09@Override%0A%09%09%09public boolean hasNext() %7B%0A%09%09%09%09return index %3C elements.length;%0A%09%09%09%7D%0A%0A%09%09%09@Override%0A%09%09%09public T next() %7B%0A%09%09%09%09if(hasNext()) %7B%0A%09%09%09%09%09return elements%5Bindex++%5D;%0A%09%09%09%09%7D%0A%09%09%09%09throw new NoSuchElementException(%22%22 + index);%0A%09%09%09%7D%0A%09%09%7D
+public T%5B%5D getElements() %7B%0A%09%09return elements
 ;%0A%09%7D
-%0A
 %09%0A%7D

Change to return array of elements instead of implementing iterable.