// Shaun Conlon // This class represents a linked list of integers. public class IntList { private IntNode head; private IntNode tail; public IntList(IntNode start) { head = tail = start; } public void setHead(IntNode head) { this.head = head; } public IntNode getHead() { return head; } public void setTail(IntNode tail) { this.tail = tail; } public IntNode getTail() { return tail; } // adds a node to the tail of the list public void add(IntNode next) { tail.setNext(next); setTail(next); } // iterator class for an IntList public IntListIterator implements Iterator { private IntNode current; public IntListIterator(IntList l) { current = l.getHead(); } public boolean hasNext() { return (current != null); } public Object next() { Integer i = new Integer(current.getData()); current = current.getNext(); return i; } } // returns an Iterator for this list public Iterator iterator() { return new IntListIterator(this); } }