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;

Author:
Roger Whitney (whitney@cs.sdsu.edu)
See Also:
List, Comparer, SortedCollection

Variable Index

 o order

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 addArray(Object[])
Adds an array of elements to the sorted list.
 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 insertionIndexOf(Object)
 o integerSorter()
Returns a sortedList object that will sort integers.
 o main(String[])
 o merge(Object[], int, Object[], int)
Returns the result of merging the first leftLength elements of array left and the first rightLength elements of array right.
 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 sort(Object[], int, int)
Sorts the list elements from lowIndex to highIndex
 o stringSorter()
Returns a sortedList object that will sort strings.

Variables

 o order
 protected Comparer order

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 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
 o addArray
 protected void addArray(Object elementsToAdd[])
Adds an array of elements to the sorted list. Changes the array elementsToAdd

 o merge
 protected Object[] merge(Object left[],
                          int leftLength,
                          Object right[],
                          int rightLenght)
Returns the result of merging the first leftLength elements of array left and the first rightLength elements of array right. Requires that left and right are sorted using current comparer object.

 o sort
 protected void sort(Object list[],
                     int lowIndex,
                     int highIndex)
Sorts the list elements from lowIndex to highIndex

 o insertionIndexOf
 protected int insertionIndexOf(Object item)
 o main
 public static void main(String argv[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index