Interface SimpleList

All Known Implementing Classes:
LinkedSimpleList

public abstract interface SimpleList

An interface for a simple list ADT. Note that this ADT does not specify how the list is ordered. No method is required for finding an element on the list. This is simply a "barebones" list ADT which can be used to introduce the concepts of lists and ADTs.


Method Summary
 void advance()
          Advances the current position in the list by one element.
 void append(java.lang.Object element)
          Appends a new element to the end of the list.
 void clear()
          Empties all elements from the list.
 java.lang.Object getCurrent()
          Retrieves the Object at the current position in the list.
 void insert(java.lang.Object element)
          Inserts a new element in front of the current position.
 boolean isEmpty()
          Determines whether or not the list is empty.
 boolean isInList()
          Determines whether or not the current position actually refers to a valid position in the list.
 int length()
          Determines and returns the number of elements in the list.
 void print()
          Prints the elements in the list to standard output.
 java.lang.Object remove()
          Removes the element at the current position in the list.
 void setCurrent(java.lang.Object element)
          Replaces the element at the current position in the list with the specified parameter.
 void setFirst()
          Sets the current position in the list to point to the first element.
 

Method Detail

clear

public void clear()
Empties all elements from the list. Resets the list to its initial empty state.

insert

public void insert(java.lang.Object element)
Inserts a new element in front of the current position.
Parameters:
element - Object to insert in from of current position.

append

public void append(java.lang.Object element)
Appends a new element to the end of the list.
Parameters:
element - Object to be appended to the end of the list.

remove

public java.lang.Object remove()
                        throws BoundaryViolationException
Removes the element at the current position in the list.
Returns:
the Object that was removed from the current position.
Throws:
BoundaryViolationException - if the current position in the list is before the first element or after the last element.

getCurrent

public java.lang.Object getCurrent()
                            throws BoundaryViolationException
Retrieves the Object at the current position in the list.
Returns:
the Object at the current position in the list.
Throws:
BoundaryViolationException - if the current position in the list is before the first position or after the last position.

setCurrent

public void setCurrent(java.lang.Object element)
                throws BoundaryViolationException
Replaces the element at the current position in the list with the specified parameter.
Parameters:
element - Object to copy to the current position.
Throws:
BoundaryViolationException - If the current position in the list is after the last position or before the first position in the list.

setFirst

public void setFirst()
Sets the current position in the list to point to the first element.

advance

public void advance()
             throws BoundaryViolationException
Advances the current position in the list by one element.
Throws:
BoundaryViolationException - If the current position is past the last element or before the first element in the list.

length

public int length()
Determines and returns the number of elements in the list.
Returns:
the number of elements in the list.

isEmpty

public boolean isEmpty()
Determines whether or not the list is empty.
Returns:
true is the list contains at least one element, false otherwise.

isInList

public boolean isInList()
Determines whether or not the current position actually refers to a valid position in the list.
Returns:
the status of the current position: true if the current position is the first position, the last position, or any position in between, false otherwise.

print

public void print()
Prints the elements in the list to standard output.