
/**
 * List.java
 *
 *
 * Created: Mon Oct 07 22:26:41 2002
 *
 * @author <a href="mailto: "</a>
 * @version
 */
package containers;
public class List implements IContainer{

   private AListNode state;
   
   //state related operations
   // package visibility only 
   AListNode getState(){
      return state;
   }
   
   void changeState(AListNode n){
      state = n;
    }

   public List (){
      state = EmptyListNode.singleton(); 
      // null object instead of null pointer   
   }


   public Object head() {
      return(state.head());  // delegate to state where it will be
      // polymorphically dispatched
      // instead of if head == null return null
      // else return something
   }
      
   public List tail() {
      return (state.tail());  // same as above
   }

   public boolean removeFirst() {
      System.out.println();
      System.out.println("List: Want to remove first node ");
      return (state.removeFirst(this));
   }

   public void addFirst(Object o)
   {
      System.out.println();
      System.out.println("List : Want to add " + o);
      state.addFirst(o,this);
   }


}// List

