structure
Class SinglyLinkedListElement<ELTTYPE>

java.lang.Object
  extended by structure.SinglyLinkedListElement<ELTTYPE>

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


Constructor Summary
SinglyLinkedListElement(ELTTYPE v)
          Constructs a singly linked list element not associated with any list.
SinglyLinkedListElement(ELTTYPE v, SinglyLinkedListElement<ELTTYPE> next)
          Construct a singly linked list element.
 
Method Summary
 SinglyLinkedListElement<ELTTYPE> next()
           
 void setNext(SinglyLinkedListElement<ELTTYPE> next)
          Update the next element.
 void setValue(ELTTYPE value)
          Set the value associated with this element.
 java.lang.String toString()
          Construct a string representation of element.
 ELTTYPE 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(ELTTYPE v,
                               SinglyLinkedListElement<ELTTYPE> 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.
Pre:
v is a value, next is a reference to remainder of list
Post:
an element is constructed as the new head of list

SinglyLinkedListElement

public SinglyLinkedListElement(ELTTYPE 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.
Post:
constructs a new tail of a list with value v
Method Detail

next

public SinglyLinkedListElement<ELTTYPE> next()
Post:
returns reference to next value in list

setNext

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

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

value

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

Returns:
Reference to the value stored within this element.
Post:
returns value associated with this element

setValue

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

Parameters:
value - The new value to be associated with this element.
Post:
sets value 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.
Post:
returns string representation of element