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
-
order
-
-
SortedList(Comparer)
- Create a new SortedList using the Comparer object listOrder to
define the order on elements.
-
SortedList(Comparer, int)
- Create a new SortedList using the Comparer object listOrder to
define the order on elements.
-
addArray(Object[])
- Adds an array of elements to the sorted list.
-
addElement(Object)
- Adds the specified object in proper location to keep list sorted.
-
addElements(Object[])
- Adds the elements of an array to a SortedList.
-
addElements(SortedCollection)
- Adds the elements of a SortedCollection to a SortedList.
-
addElements(Vector)
- Adds the elements of a Vector to a SortedList.
-
clone()
- Clones this list.
-
doubleSorter()
- Returns a sortedList object that will sort floats and doubles.
-
getComparer()
- Returns the comparer object used to order list.
-
indexOf(Object, int)
- Searches for the specified object, starting at the specified
position and returns an index to it.
-
insertionIndexOf(Object)
-
-
integerSorter()
- Returns a sortedList object that will sort integers.
-
main(String[])
-
-
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.
-
resort(Comparer)
- Resorts the list using the new comparer to define
the ordering of the elements.
-
reversed()
- Returns a SortedList with elements in the reverse order
from present SortedList
-
sort(Object[], int, int)
- Sorts the list elements from lowIndex to highIndex
-
stringSorter()
- Returns a sortedList object that will sort strings.
order
protected Comparer order
SortedList
public SortedList(Comparer listOrder)
- Create a new SortedList using the Comparer object listOrder to
define the order on elements.
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.
integerSorter
public static SortedList integerSorter()
- Returns a sortedList object that will sort integers.
doubleSorter
public static SortedList doubleSorter()
- Returns a sortedList object that will sort floats and doubles.
stringSorter
public static SortedList stringSorter()
- Returns a sortedList object that will sort strings.
getComparer
public Comparer getComparer()
- Returns the comparer object used to order list.
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
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
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
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
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
reversed
public synchronized OrderedCollection reversed()
- Returns a SortedList with elements in the reverse order
from present SortedList
- Overrides:
- reversed in class List
resort
public synchronized void resort(Comparer newOrder)
- Resorts the list using the new comparer to define
the ordering of the elements.
clone
public synchronized Object clone()
- Clones this list. The elements are not cloned.
- Overrides:
- clone in class List
addArray
protected void addArray(Object elementsToAdd[])
- Adds an array of elements to the sorted list.
Changes the array elementsToAdd
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.
sort
protected void sort(Object list[],
int lowIndex,
int highIndex)
- Sorts the list elements from lowIndex to highIndex
insertionIndexOf
protected int insertionIndexOf(Object item)
main
public static void main(String argv[])
All Packages Class Hierarchy This Package Previous Next Index