package username.linear; /** * A node in a simple implementation of queues. Each node contains * a value and a link to the next node in the queue. The next node * is null for the last value in the queue. * * @author Samuel A. Rebelsky * @version 1.1 of March 2006. */ // +-------+------------------------------------------------------------- // | Notes | // +-------+ /* (1) This class is intentionally *not* public, as QueueNodes should only be used by LinkedQueue (and, potentially, by other data structures). (2) Although it is generally a bad idea to use the fields of a class directly (at least not from another class), we assume that LinkedQueue will, in fact, access those fields directly (primarily getting them, but setting them once in a while) and provide neither accessors nor setters. */ class QueueNode { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** * The contents of the node. The current value in the queue. */ public T contents; /** * The node that contains the next value in the queue. If this * value is the last one in the queue, the next node is null. */ public QueueNode next; // +-------------+------------------------------------------------------- // | Construtors | // +-------------+ /** * Create a node with no next value. */ public QueueNode(T _contents) { this.contents = _contents; this.next = null; } // QueueNode(Object) /** * Create a node with a specified next node. */ public QueueNode(T _contents, QueueNode _next) { this.contents = _contents; this.next = _next; } // QueueNode(T, QueueNode) } // class QueueNode