UNB/ CS/ David Bremner/ teaching/ java/ SingleLinked.java
import java.util.Iterator;


class SingleIterator
    implements java.util.Iterator{
    
    private ListNode cursor,previous;

    public SingleIterator(SingleListNodeed list){
        previous=null;
        cursor=list.getFirst();
    }

    public boolean hasNext(){
        return (cursor != null  && cursor.next !=null);
    }
    public Object next(){
        previous=cursor;
        cursor=cursor.next;
        return cursor.data;
    }

    public void remove(){
    }

}



public class SingleListNodeed {
    private ListNode first;
    
    public ListNode getFirst(){
        return first;
    }
    
    Iterator listIterator(){
        return new SingleIterator(this);
    }
}


//