// A class that uses an object of the LinkedList class to implement Queue.
// Barry Cornelius, 19 June 2000
import java.util. LinkedList;
import java.util. Iterator;
import java.util. List;
public class LinkedQueue implements Queue 
{
   private List iList;
   public LinkedQueue()
   {
      iList = new LinkedList();
   }
   public void add(final Object pObject) 
   {
      iList.add(pObject);
   }
   public Object getFirst()
   {
      if (iList.isEmpty())
      {
         return null;
      }
      return iList.get(0);
   } //BJCHEREFIRST
   public Object remove() 
   {
      if (iList.isEmpty())
      {
         return null;
      }
      return iList.remove(0);
   }
   public int size()
   {
      return iList.size();
   }
   public boolean equals(final Object pObject)
   {
      if ( pObject==null || getClass()!=pObject.getClass() )
      {
         return false;
      }
      return iList.equals(((LinkedQueue)pObject).iList);
   }
   public int hashCode()
   {
      return 0;
   }
   public String toString()
   {
      if (iList.isEmpty())
      {
         return new String("");
      }
      final StringBuffer tStringBuffer = new StringBuffer();
      final Iterator tIterator = iList.iterator();
      while (tIterator.hasNext())
      {
         final Object tObject = tIterator.next();
         tStringBuffer.append("@" + tObject);
      }
      tStringBuffer.deleteCharAt(0);
      return tStringBuffer.toString();
   }
}
