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.


Constructor Index

 o OrderedList()
Construct an empty ordered list.

Method Index

 o add(Object)
Add a value to the ordered list, keeping values in order.
 o clear()
Remove all the elements from the ordered list.
 o contains(Object)
Determine if the ordered list contains a value.
 o elements()
Construct an iterator for traversing elements of ordered list in ascending order.
 o isEmpty()
Determine if the list is empty.
 o remove(Object)
Remove a value from the ordered list.
 o size()
Determine the number of elements in the list.
 o toString()
Generate string representation of the ordered list.

Constructors

 o OrderedList
 public OrderedList()
Construct an empty ordered list.

Postcondition:
constructs an empty ordered list.

Methods

 o clear
 public void clear()
Remove all the elements from the ordered list.

Postcondition:
the ordered list is empty

 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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