/*
 * Copyright (C) 1998, Center for Geometric Computing, Brown University
 *                 and The Johns Hopkins University
 * 
 * All Rights Reserved
 * 
 * 
 */

//package jdsl;


/**
 * This class represents a node of a sigly-linked list. Each node stores a   
 * reference which follows it in the list and a reference to an element it 
 * it contains.
 *   
 * @version JSDL-Teach release 1.0
 * @author Natasha Gelfand
 */

public class SLNode {
  private Object element;  // element stored in this node
  private SLNode next; // reference to the next node in the list
  
  // constructors
  /** 
    * Default constructor, creates a node with a null element and null next. 
    */
  public SLNode() {  //# create a node with a null element and next reference
    this(null, null);
  }
  
  /**
    * Create a node with the given element; next is set to null.
    * @param e Element to be stored in this node.
    */
  public SLNode(Object e)
    {
      element = e;
      next = null;
    }

  /** 
    * Create a node with the given element and next reference
    * @param e  Element stored in this node.
    * @param n  Reference to the next element in the list.
    */
  public SLNode(Object e, SLNode n) { //# create a node given element and next
    element = e;
    next = n;
  }
  // update methods
  public void setElement(Object newElem) { element = newElem; }
  public void setNext(SLNode newNext) { next = newNext; }
  // accessor methods
  public Object getElement() { return element; }
  public SLNode getNext() { return next; }
}

