All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Interface structure.List

public interface List
extends Collection
Interface describing lists. Lists are collections of data with a head and tail. Values may be added or removed from either end, as well as by value from the middle.

See Also:
SinglyLinkedList, DoublyLinkedList, CircularlyLinkedList

Method Index

 o add(Object)
Add an object 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 elements of list.
 o contains(Object)
Check to see if a value is in the list.
 o elements()
Construct an iterator to traverse elements of the list from head to tail, in order.
 o isEmpty()
Determine if list is empty.
 o peek()
Fetch the first element of the list.
 o remove(Object)
Remove a value from the list.
 o removeFromHead()
Remove a value from the first element of the list.
 o removeFromTail()
Remove the last value from the list.
 o size()
Determine size of list.
 o tailPeek()
Fetch the last element of the list.

Methods

 o elements
public abstract Iterator elements()
Construct an iterator to traverse elements of the list from head to tail, in order.

Postcondition:
returns an iterator allowing ordered traversal of elements in list

Returns:
Iterator that traverses list.
 o size
public abstract int size()
Determine size of list.

Postcondition:
returns number of elements in list

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

Postcondition:
returns true iff list has no elements

Returns:
True if list has no elements.
 o clear
public abstract void clear()
Remove all elements of list.

Postcondition:
empties list

 o add
public abstract void add(Object value)
Add an object to the head of the list.

Postcondition:
value is added to beginning of list (see addToHead)

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

Postcondition:
value is added to beginning of list

Parameters:
value - The value to be added to the head of the list.
 o addToTail
public abstract void addToTail(Object value)
Add a value to the tail of the list.

Postcondition:
value is added to end of list

Parameters:
value - The value to be added to the tail of the list.
 o peek
public abstract Object peek()
Fetch the first element of the list.

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

Returns:
A reference to first element of the list.
 o tailPeek
public abstract Object tailPeek()
Fetch the last element of the list.

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

Returns:
A reference to the last element of the list.
 o removeFromHead
public abstract Object removeFromHead()
Remove a value from the first element of the list.

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

Returns:
The value actually removed.
 o removeFromTail
public abstract Object removeFromTail()
Remove the last value from the list.

Precondition:
list is not empty
Postcondition:
removes the last value from the list

Returns:
The value actually removed.
 o contains
public abstract boolean contains(Object value)
Check to see if a value is in the list.

Precondition:
value is not null
Postcondition:
returns true iff list contains an object equal to value

Parameters:
value - The value sought.
Returns:
True if the value is within the list.
 o remove
public abstract Object remove(Object value)
Remove a value from the list. At most one of the value will be removed.

Postcondition:
removes and returns element equal to value otherwise returns null

Parameters:
value - The value to be removed.
Returns:
The actual value removed.

All Packages  Class Hierarchy  This Package  Previous  Next  Index