Class Listnode<E>

java.lang.Object
  extended by Listnode<E>
Type Parameters:
E - the generic type of the data content stored in the list DO NOT EDIT OR HAND IN THIS CLASS

public class Listnode<E>
extends java.lang.Object

The internal node structure of LinkedList.


Field Summary
private  E data
          A reference to the data item for this node.
private  Listnode<E> next
          A reference to the next node in a singly linked chain of nodes.
 
Constructor Summary
Listnode(E data)
          Constructs a new list node with no link to a next node in the chain.
Listnode(E data, Listnode<E> next)
          Constructs a new list node with a link to the next node in a chain of nodes.
 
Method Summary
 E getData()
          Returns a reference to data item for this node.
 Listnode<E> getNext()
          Returns a reference to the next node after this node.
 void setData(E data)
          Changes what data is referenced by this node.
(package private)  void setNext(Listnode<E> next)
          Changes what node is next after this node in a chain of node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

private E data
A reference to the data item for this node. May be null if this node is used a header node or other.


next

private Listnode<E> next
A reference to the next node in a singly linked chain of nodes. May be null if this node is the last node in the chain.

Constructor Detail

Listnode

public Listnode(E data)
Constructs a new list node with no link to a next node in the chain.

Parameters:
data - the data to be stored in this node. The data reference may be null.

Listnode

public Listnode(E data,
                Listnode<E> next)
Constructs a new list node with a link to the next node in a chain of nodes.

Parameters:
data - the data to be stored in this node. May be null.
next - the node after this one. May be null.
Method Detail

getData

public E getData()
Returns a reference to data item for this node.

Returns:
the current data

getNext

public Listnode<E> getNext()
Returns a reference to the next node after this node.

Returns:
the next node in the chain

setData

public void setData(E data)
Changes what data is referenced by this node.

Parameters:
data - the new data

setNext

void setNext(Listnode<E> next)
Changes what node is next after this node in a chain of node.

Parameters:
the - new next node