package list;
/** Represents a node that stores arbitrary objects and maintains
* a link to another node.
* @author Jan Stelovsky
* @inspiration E. Biagioni & W. Albritton */
public class Node<Type> {
/* The link to the next node in the linked list.
* If there is no next node, the pointer is null. */
private Type value;
/** The data object that this node contains. */
private Node<Type> next;
/** Creates a new Node.
* @param value the data objects within the node
* @param next the next node in the linked list */
public Node (Type value, Node<Type> next) {
this.value = value;
this.next = next;
}
/* accessor methods */
/** Returns the data contained in this Node.
* @return the object within this Node */
public Type value () {
return value;
}
/** Returns the next node in the linked list.
* @return reference to the next Node */
public Node<Type> next () {
return next;
}
/* mutator methods */
/** Sets the data that this Node should hold.
* @param the object this Node should store */
public void setValue(Type value) {
this.value = value;
}
/** Sets the next node in the linked list.
* @param reference to the next Node */
public void setNext (Node<Type> next) {
this.next = next;
}
}