All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.util.SortedList

java.lang.Object
   |
   +----sdsu.util.List
           |
           +----sdsu.util.SortedList

public class SortedList
extends List
implements SortedCollection
A SortedList is a list of objects kept in sorted order. A Comparer object is needed to compare objects in the list, as there is no standard compare operation for objects. Comparer class for standard types are found in the package sdsu.compare. For object types not covered, make a sublclass of sdsu.compare.Comparer;

Version:
2.0 10 January 1998
Author:
Roger Whitney (whitney@cs.sdsu.edu), Mark Boyns
See Also:
List, Comparer, SortedCollection

Constructor Index

 o SortedList(Comparer)
Create a new SortedList using the Comparer object listOrder to define the order on elements.
 o SortedList(Comparer, int)
Create a new SortedList using the Comparer object listOrder to define the order on elements.

Method Index

 o addElement(Object)
Adds the specified object in proper location to keep list sorted.
 o addElements(Object[])
Adds the elements of an array to a SortedList.
 o addElements(SortedCollection)
Adds the elements of a SortedCollection to a SortedList.
 o addElements(Vector)
Adds the elements of a Vector to a SortedList.
 o clone()
Clones this list.
 o doubleSorter()
Returns a sortedList object that will sort floats and doubles.
 o getComparer()
Returns the comparer object used to order list.
 o indexOf(Object, int)
Searches for the specified object, starting at the specified position and returns an index to it.
 o insertElementAt(Object, int)
Inserts the specified object in the proper location in the sorted list.
 o integerSorter()
Returns a sortedList object that will sort integers.
 o resort(Comparer)
Resorts the list using the new comparer to define the ordering of the elements.
 o reversed()
Returns a SortedList with elements in the reverse order from present SortedList
 o setElementAt(Object, int)
Sets the element at the specified index to be the specified object and resorts the list.
 o stringSorter()
Returns a sortedList object that will sort strings.

Constructors

 o SortedList
 public SortedList(Comparer listOrder)
Create a new SortedList using the Comparer object listOrder to define the order on elements.

 o SortedList
 public SortedList(Comparer listOrder,
                   int initialSize)
Create a new SortedList using the Comparer object listOrder to define the order on elements. The sortedlist will have room for initialSize elements before it needs to grow.

Methods

 o integerSorter
 public static SortedList integerSorter()
Returns a sortedList object that will sort integers.

 o doubleSorter
 public static SortedList doubleSorter()
Returns a sortedList object that will sort floats and doubles.

 o stringSorter
 public static SortedList stringSorter()
Returns a sortedList object that will sort strings.

 o getComparer
 public Comparer getComparer()
Returns the comparer object used to order list.

 o addElement
 public void addElement(Object elementToAdd)
Adds the specified object in proper location to keep list sorted.

Parameters:
elementToAdd - the element to be added
Overrides:
addElement in class List
 o addElements
 public void addElements(SortedCollection elementsToAdd)
Adds the elements of a SortedCollection to a SortedList. Resulting list is sorted

Parameters:
elementsToAdd - the elements to be added
 o addElements
 public void addElements(Vector elementsToAdd)
Adds the elements of a Vector to a SortedList. Resulting list is sorted

Parameters:
elementsToAdd - the elements to be added
Overrides:
addElements in class List
 o addElements
 public void addElements(Object elementsToAdd[])
Adds the elements of an array to a SortedList. Resulting list is sorted

Parameters:
elementsToAdd - the elements to be added
Overrides:
addElements in class List
 o indexOf
 public final synchronized int indexOf(Object elem,
                                       int index)
Searches for the specified object, starting at the specified position and returns an index to it.

Parameters:
elem - the desired element
index - the index where to start searching
Returns:
the index of the element, or -1 if it was not found.
Overrides:
indexOf in class List
 o insertElementAt
 public synchronized void insertElementAt(Object object,
                                          int index)
Inserts the specified object in the proper location in the sorted list. Should not this method on sorted list. Use addElement.

Parameters:
object - the element to insert
index - not used
Overrides:
insertElementAt in class List
 o setElementAt
 public synchronized void setElementAt(Object object,
                                       int index)
Sets the element at the specified index to be the specified object and resorts the list. The previous element at that position is discarded.

Parameters:
object - what the element is to be set to
index - the specified index
Throws: ArrayIndexOutOfBoundsException
If the index was invalid.
Overrides:
setElementAt in class List
 o reversed
 public synchronized OrderedCollection reversed()
Returns a SortedList with elements in the reverse order from present SortedList

Overrides:
reversed in class List
 o resort
 public synchronized void resort(Comparer newOrder)
Resorts the list using the new comparer to define the ordering of the elements.

 o clone
 public synchronized Object clone()
Clones this list. The elements are not cloned.

Overrides:
clone in class List

All Packages  Class Hierarchy  This Package  Previous  Next  Index