All Packages Class Hierarchy This Package Previous Next Index
Class structure.OrderedList
java.lang.Object
|
+----structure.OrderedList
- public class OrderedList
- extends Object
- implements OrderedStructure
A class that implements a collection of values that are kept in order.
Base values must be comparable. Unlike Lists there is no notion of head
or tail.
OrderedList()
- Construct an empty ordered list.
add(Object)
- Add a value to the ordered list, keeping values in order.
clear()
- Remove all the elements from the ordered list.
contains(Object)
- Determine if the ordered list contains a value.
elements()
- Construct an iterator for traversing elements of ordered list
in ascending order.
isEmpty()
- Determine if the list is empty.
remove(Object)
- Remove a value from the ordered list.
size()
- Determine the number of elements in the list.
toString()
- Generate string representation of the ordered list.
OrderedList
public OrderedList()
- Construct an empty ordered list.
- Postcondition:
- constructs an empty ordered list.
clear
public void clear()
- Remove all the elements from the ordered list.
- Postcondition:
- the ordered list is empty
add
public void add(Object value)
- Add a value to the ordered list, keeping values in order.
- Precondition:
- value is non-null
- Postcondition:
- value is added to the list, leaving it in order
- Parameters:
- value - The value to be added to the list.
contains
public boolean contains(Object value)
- Determine if the ordered list contains a value.
- Precondition:
- value is non-null comparable object
- Postcondition:
- returns true iff contains value
- Parameters:
- value - The value sought in the list.
- Returns:
- The actual value found, or null, if not.
remove
public Object remove(Object value)
- Remove a value from the ordered list. At most one value
is removed.
- Precondition:
- value is non-null
- Postcondition:
- an instance of value is removed, if in list.
- Parameters:
- value - The value to be removed.
- Returns:
- The actual value removed from the list.
size
public int size()
- Determine the number of elements in the list.
- Precondition:
- returns the number of elements in the ordered list
- Returns:
- The number of elements in the list.
isEmpty
public boolean isEmpty()
- Determine if the list is empty.
- Postcondition:
- returns true iff the size is non-zero
- Returns:
- True if the ordered list is empty.
elements
public Iterator elements()
- Construct an iterator for traversing elements of ordered list
in ascending order.
- Postcondition:
- returns an iterator over ordered list
- Returns:
- An iterator traversing elements in ascending order.
toString
public String toString()
- Generate string representation of the ordered list.
- Postcondition:
- returns string representation of list
- Returns:
- String representing ordered list.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index