© 1998-2002 McGraw-Hill

structure
Class DoublyLinkedListElement

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

public class DoublyLinkedListElement
extends Object

A class supporting a doubly linked list element. Each element contains a value and maintains references to the previous and next nodes in the list.

See Also:
DoublyLinkedList

Field Summary
protected  Object data
          The actual value stored within element; provided by user.
protected  DoublyLinkedListElement nextElement
          The reference of element following.
protected  DoublyLinkedListElement previousElement
          The reference to element preceding.
 
Constructor Summary
DoublyLinkedListElement(Object v)
          Construct a doubly linked list element containing a value.
DoublyLinkedListElement(Object v, DoublyLinkedListElement next, DoublyLinkedListElement previous)
          Construct a doubly linked list element.
 
Method Summary
 boolean equals(Object other)
          Determine if this element equal to another.
 int hashCode()
          Generate hash code associated with the element.
 DoublyLinkedListElement next()
          Access the reference to the next value.
 DoublyLinkedListElement previous()
          Get a reference to the previous element of the list.
 void setNext(DoublyLinkedListElement next)
          Set reference to the next element.
 void setPrevious(DoublyLinkedListElement previous)
          Set the reference to the previous element.
 void setValue(Object value)
          Set the value of the element.
 String toString()
          Construct a string representation of the element.
 Object value()
          Get value stored within the element.
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

data

protected Object data
The actual value stored within element; provided by user.

nextElement

protected DoublyLinkedListElement nextElement
The reference of element following.

previousElement

protected DoublyLinkedListElement previousElement
The reference to element preceding.
Constructor Detail

DoublyLinkedListElement

public DoublyLinkedListElement(Object v,
                               DoublyLinkedListElement next,
                               DoublyLinkedListElement previous)
Construct a doubly linked list element.
Parameters:
v - The value associated with the element.
next - The reference to the next element.
previous - The reference to the previous element.

DoublyLinkedListElement

public DoublyLinkedListElement(Object v)
Construct a doubly linked list element containing a value. Not part of any list (references are null).
Parameters:
v - The value referenced by this element.
Method Detail

next

public DoublyLinkedListElement next()
Access the reference to the next value.
Postcondition:
returns the element that follows this
Returns:
Reference to the next element of the list.

previous

public DoublyLinkedListElement previous()
Get a reference to the previous element of the list.
Postcondition:
returns element that precedes this
Returns:
Reference to the previous element.

value

public Object value()
Get value stored within the element.
Postcondition:
returns value stored here
Returns:
The reference to the value stored.

setNext

public void setNext(DoublyLinkedListElement next)
Set reference to the next element.
Parameters:
next - The reference to the new next element.
Postcondition:
sets value associated with this element

setPrevious

public void setPrevious(DoublyLinkedListElement previous)
Set the reference to the previous element.
Parameters:
previous - The new previous element.
Postcondition:
establishes a new reference to a previous value

setValue

public void setValue(Object value)
Set the value of the element.
Parameters:
value - The new value associated with the element.
Postcondition:
sets a new value for this object

equals

public boolean equals(Object other)
Determine if this element equal to another.
Overrides:
equals in class Object
Parameters:
other - The other doubly linked list element.
Postcondition:
returns true if this object and other are equal
Returns:
True iff the values within elements are the same.

hashCode

public int hashCode()
Generate hash code associated with the element.
Overrides:
hashCode in class Object
Postcondition:
generates hash code for element
Returns:
The hash code associated with the value in element.

toString

public String toString()
Construct a string representation of the element.
Overrides:
toString in class Object
Postcondition:
returns string representation of element
Returns:
The string representing element.

© 1998-2002 McGraw-Hill