package username.lists; /** * Nodes from which we build linked lists. * * @author Samuel A. Rebelsky * @version 1.0 of April 2006 */ class Node implements Position { // +------------------+------------------------------------- // | Design Decisions | // +------------------+ /* (1) The fields of nodes are intentionally accessible to other classes in this package. Hence, there are no setters and getters. */ // +--------+----------------------------------------------- // | Fields | // +--------+ /** * The value stored in the node. */ V val; /** * The next node. */ Node next; // +--------------+----------------------------------------- // | Constructors | // +--------------+ public Node(V _value) { this.val = _value; this.next = null; } // Node(V) public Node(V _value, Node _next) { this.val = _value; this.next = _next; } // Node(V, Node) // +------------------+------------------------------------- // | Standard Methods | // +------------------+ public int hashCode() { return this.val.hashCode(); } // hashCode() @SuppressWarnings({"unchecked"}) public boolean equals(Object other) { try { return this.equals((Node) other); } catch (Exception e) { return false; } } // equals(Object) public boolean equals(Node other) { return this.val.equals(other.val); } // equals(Node) } // class Node