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
add(Object)
- Add an object to the head of the list.
addToHead(Object)
- Add a value to the head of the list.
addToTail(Object)
- Add a value to the tail of the list.
clear()
- Remove all elements of list.
contains(Object)
- Check to see if a value is in the list.
elements()
- Construct an iterator to traverse elements of the list
from head to tail, in order.
isEmpty()
- Determine if list is empty.
peek()
- Fetch the first element of the list.
remove(Object)
- Remove a value from the list.
removeFromHead()
- Remove a value from the first element of the list.
removeFromTail()
- Remove the last value from the list.
size()
- Determine size of list.
tailPeek()
- Fetch the last element of the list.
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.
size
public abstract int size()
- Determine size of list.
- Postcondition:
- returns number of elements in list
- Returns:
- The number of elements in list.
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.
clear
public abstract void clear()
- Remove all elements of list.
- Postcondition:
- empties list
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
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.
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.
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.
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.
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.
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.
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.
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