structure
Class SinglyLinkedListElement

java.lang.Object
  |
  +--structure.SinglyLinkedListElement

public class SinglyLinkedListElement
extends java.lang.Object

A class supporting a singly linked list element. Each element contains a value and maintains a single reference to the next node in the list.


Field Summary
protected  java.lang.Object data
          The data value stored in this node.
protected  SinglyLinkedListElement nextElement
          Reference to the next node in the list.
 
Constructor Summary
SinglyLinkedListElement(java.lang.Object v)
          Constructs a singly linked list element not associated with any list.
SinglyLinkedListElement(java.lang.Object v, SinglyLinkedListElement next)
          Construct a singly linked list element.
 
Method Summary
 SinglyLinkedListElement next()
           
 void setNext(SinglyLinkedListElement next)
          Update the next element.
 void setValue(java.lang.Object value)
          Set the value associated with this element.
 java.lang.String toString()
          Construct a string representation of element.
 java.lang.Object value()
          Fetch the value associated with this element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

protected java.lang.Object data
The data value stored in this node.


nextElement

protected SinglyLinkedListElement nextElement
Reference to the next node in the list.

Constructor Detail

SinglyLinkedListElement

public SinglyLinkedListElement(java.lang.Object v,
                               SinglyLinkedListElement next)
Construct a singly linked list element.

Parameters:
v - The value to be referenced by this element.
next - A reference to the next value in the list.

SinglyLinkedListElement

public SinglyLinkedListElement(java.lang.Object v)
Constructs a singly linked list element not associated with any list. next reference is set to null.

Parameters:
v - The value to be inserted into the singly linked list element.
Method Detail

next

public SinglyLinkedListElement next()

setNext

public void setNext(SinglyLinkedListElement next)
Update the next element.

Parameters:
next - The new value of the next element reference.

value

public java.lang.Object value()
Fetch the value associated with this element.

Returns:
Reference to the value stored within this element.

setValue

public void setValue(java.lang.Object value)
Set the value associated with this element.

Parameters:
value - The new value to be associated with this element.

toString

public java.lang.String toString()
Construct a string representation of element.

Overrides:
toString in class java.lang.Object
Returns:
The string representing element.