/**
 * The building blocks of doubly-linked lists.
 *
 * @author Samuel A. Rebelsky
 * @author Yvonne Palm
 * @author Alex Leach
 * @author Jonathan Wellons
 */
public class DoublyLinkedNode
{
  // +--------+---------------------------------------------------
  // | Fields |
  // +--------+

  /**
   * The previous node.  Null if it's the first node.
   */
  DoublyLinkedNode prev;

  /**
   * The value stored in this node.
   */
  Object contents;
  /**
   * The next node.  Null if it's the last node.
   */
  DoublyLinkedNode next;

  // +--------------+---------------------------------------------
  // | Constructors |
  // +--------------+

  /**
   * Build a new doubly-linked node with particular contents.
   * Assume next and prev are both null.
   */
  public DoublyLinkedNode(Object contents)
  {
    // Call the other constructor.
    this(null, contents, null);
  } // DoublyLinkedNode(Object)

  /**
   * Build a new doubly-linked node, filling in all three fields.
   */
  public DoublyLinkedNode(DoublyLinkedNode prev,
                          Object contents,
                          DoublyLinkedNode next)
  {
    this.prev = prev;
    this.contents = contents;
    this.next = next;
  } // DoublyLinkedNode(DoublyLinkedNode, Object, DoublyLinkedNode)

} // class DoublyLinkedNode
