structure5
Class SinglyLinkedListElement<E>

java.lang.Object
  extended by structure5.SinglyLinkedListElement<E>

public class SinglyLinkedListElement<E>
extends 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.


Constructor Summary
SinglyLinkedListElement(E v)
          Constructs a singly linked list element not associated with any list.
SinglyLinkedListElement(E v, SinglyLinkedListElement<E> next)
          Construct a singly linked list element.
 
Method Summary
 SinglyLinkedListElement<E> next()
           
 void setNext(SinglyLinkedListElement<E> next)
          Update the next element.
 void setValue(E value)
          Set the value associated with this element.
 String toString()
          Construct a string representation of element.
 E value()
          Fetch the value associated with this element.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SinglyLinkedListElement

public SinglyLinkedListElement(E v,
                               SinglyLinkedListElement<E> 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(E 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<E> next()

setNext

public void setNext(SinglyLinkedListElement<E> next)
Update the next element.

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

value

public E value()
Fetch the value associated with this element.

Returns:
Reference to the value stored within this element.

setValue

public void setValue(E value)
Set the value associated with this element.

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

toString

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

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