import java.util.Iterator;
public class Set<E extends Object> {
private Node<E> head;
private class Node<E> {
Node<E> next;
E value;
}
public void add(E e) {
Node<E> oldHead = head;
head = new Node<E>();
head.value = e;
head.next = oldHead;
}
public Iterator<E> iterator() {return new MyIterator();}
private class MyIterator implements Iterator<E>
{
private Node<E> current = head;
public boolean hasNext() {return current != null;}
public void remove() {}
public E next(){
E e = current.value;
current = current.next;
return e;}
}
}