All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class structure.DoublyLinkedList

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

public class DoublyLinkedList
extends Object
implements List
An implementation of lists that makes use of doubly linked elements. This provided efficient implementation of both head and tail operations.


Constructor Index

 o DoublyLinkedList()
Constructs an empty list.

Method Index

 o add(Object)
Add a value to the head of the list.
 o addToHead(Object)
Add a value to the head of the list.
 o addToTail(Object)
Add a value to the tail of the list.
 o clear()
Remove all values from list.
 o contains(Object)
Check to see if a value is within the list.
 o elements()
Construct an iterator to traverse the list.
 o isEmpty()
Determine if the list is empty.
 o peek()
Get a copy of the first value found in the list.
 o remove(Object)
Remove a value from the list.
 o removeFromHead()
Remove a value from the head of the list.
 o removeFromTail()
Remove a value from the tail of the list.
 o size()
Determine the number of elements in the list.
 o tailPeek()
Get a copy of the last value found in the list.
 o toString()
Construct a string representation of the list.

Constructors

 o DoublyLinkedList
public DoublyLinkedList()
Constructs an empty list.

Postcondition:
constructs an empty list

Methods

 o add
public void add(Object value)
Add a value to the head of the list.

Postcondition:
adds value to beginning of list.

Parameters:
value - The value to be added.
See Also:
addToHead
 o addToHead
public void addToHead(Object value)
Add a value to the head of the list.

Precondition:
value is not null
Postcondition:
adds element to head of list

Parameters:
value - The value to be added.
 o removeFromHead
public Object removeFromHead()
Remove a value from the head of the list. Value is returned.

Precondition:
list is not empty
Postcondition:
removes first value from list

Returns:
The value removed from the list.
 o addToTail
public void addToTail(Object value)
Add a value to the tail of the list.

Precondition:
value is not null
Postcondition:
adds new value to tail of list

Parameters:
value - The value to be added.
 o removeFromTail
public Object removeFromTail()
Remove a value from the tail of the list.

Precondition:
list is not empty
Postcondition:
removes value from tail of list

Returns:
The value removed from the list.
 o peek
public Object peek()
Get a copy of the first value found in the list.

Precondition:
list is not empty
Postcondition:
returns first value in list.

Returns:
A reference to first value in list.
 o tailPeek
public Object tailPeek()
Get a copy of the last value found in the list.

Precondition:
list is not empty
Postcondition:
returns last value in list.

Returns:
A reference to the last value in the list.
 o contains
public boolean contains(Object value)
Check to see if a value is within the list.

Precondition:
value not null
Postcondition:
returns true iff value is in the list

Parameters:
value - A value to be found in the list.
Returns:
True if value is in list.
 o remove
public Object remove(Object value)
Remove a value from the list. At most one value is removed. Any duplicates remain. Because comparison is done with "equals," the actual value removed is returned for inspection.

Precondition:
value is not null. List can be empty.
Postcondition:
first element matching value is removed from list

Parameters:
value - The value to be removed.
Returns:
The value actually removed.
 o size
public int size()
Determine the number of elements in the list.

Postcondition:
returns the number of elements in list

Returns:
The number of elements found in the list.
 o isEmpty
public boolean isEmpty()
Determine if the list is empty.

Postcondition:
returns true iff the list has no elements.

Returns:
True iff list has no values.
 o clear
public void clear()
Remove all values from list.

Postcondition:
removes all the elements from the list

 o elements
public Iterator elements()
Construct an iterator to traverse the list.

Postcondition:
returns iterator that allows the traversal of list.

Returns:
An iterator that traverses the list from head to tail.
 o toString
public String toString()
Construct a string representation of the list.

Postcondition:
returns a string representing list

Returns:
A string representing the elements of the list.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index