/********************************************************
/** @author Sriram Pemmaraju
/** @date October 9th, 2008
**/

import java.util.*;
import java.lang.*;

public class StringLinkListIterator<String> implements Iterator<String>{

	// Data Members
	private StringLink first;
	private StringLink current;

	// Constructor
	public StringLinkListIterator(StringLink givenFirst)
	{
		first = givenFirst;
		current = null;
	}
	
	// Returns true if there is a next Link; false otherwise
	public boolean hasNext()
	{	
		if(current == null)
			return (first != null);
		
		return (current.next != null);
	}

	// Moves current to the  next Link and returns the contents of that 
	// node
	public String next()
	{
		if(!hasNext())
			throw new NoSuchElementException("There is no next element.");
		else if(current == null)
			current = first;
		else
			current = current.next;

		return (String)(current.sData);
	}

	public void remove()
	{
		throw new UnsupportedOperationException("The remove method is not supported.");
	}
}

