/**
   The class DLNode is used to built doubly linked lists.
   Each node contains an element and links to the next
   and the previous node in the list.
 
   @author      Franck van Breugel
   @version     1.2    May 15, 2000
*/
public class DLNode 
{
    private Object element; // element stored in this node
    private DLNode prev;    // previous node in list
    private DLNode next;    // next node in list

    /** Constructs a DLNode without element, previous and next node. */
    public DLNode() 
    {
        this(null, null, null);
    }

    /** 
	Constructs a DLNode with specified element, previous and next node. 
     
	@param element the element stored in this node.
	@param prev the previous node in the list.
	@param next the next node in the list.
    */
    public DLNode(Object element, DLNode prev, DLNode next) 
    {
        this.element = element;
        this.prev = prev;
        this.next = next;
    }

    /**
       Sets the element stored in this node to the specified element.

       @param element The element to be stored in this node.
    */
    public void setElement(Object element) 
    {
        this.element = element;
    }

    /**
       Sets the previous node in the list to the specified node.

       @param node The previous node in the list.
    */
    public void setPrev(DLNode prev) 
    {
        this.prev = prev;
    }

    /**
       Sets the next node in the list to the specified node.

       @param node The next node in the list.
    */
    public void setNext(DLNode next) 
    {
        this.next = next;
    }

    /**
       Returns the element stored in this node.
       
       @return The element stored in this node.
    */
    public Object getElement() 
    {
        return element;
    }

    /**
       Returns the previous node in the list.

       @return The previous node in the list.
    */
    public DLNode getPrev() 
    {
        return prev;
    }

    /**
       Returns the next node in the list.

       @return The next node in the list.
    */
    public DLNode getNext() 
    {
        return next;
    }
}
