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
-
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.
-
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.
-
insertElementAt(Object, int)
- Inserts the specified object in the proper location in the
sorted list.
-
integerSorter()
- Returns a sortedList object that will sort integers.
-
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
-
setElementAt(Object, int)
- Sets the element at the specified index to be the specified object
and resorts the list.
-
stringSorter()
- Returns a sortedList object that will sort strings.
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
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
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
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
All Packages Class Hierarchy This Package Previous Next Index