java.lang.Object
|
+--stec.lang.QuickSort
public abstract class QuickSort
Abstract class for sorting objects.
Methods
Method
|
Description
|
compare
|
Compares the two objects.
|
count
|
Returns the number of objects to sort.
|
extract
|
Returns the specified object.
|
replace
|
Overwrites the specified object with the given object.
|
sort
|
Sorts the given objects.
|
compare
Compares the two objects.
Syntax
public abstract int compare(Object object1, Object object2)
Parameters
object1
|
the object to compare.
|
object1
|
the object to compare to.
|
Returns
int
|
a negative value if the first object is less than the second object, zero if
both objects are equal and a positive value if the first object is greater
than the second object.
|
Throws
Example
public int compare(Object object1, Object object2)
{
return ((String) object1).compareTo((String)object2);
}
count
Returns the number of objects to sort.
Syntax
public abstract int count(Object objects)
Parameters
objects
|
the objects to count.
|
Returns
int
|
the number of objects.
|
Throws
Example
public int count(Object objects)
{
return ((String[])objects).length;
}
extract
Returns the specified object.
Syntax
public abstract Object extract(Object objects, int index)
Parameters
objects
|
the objects to use.
|
index
|
the index of the object to return.
|
Returns
Object
|
the object at the specified index.
|
Throws
Example
public Object extract(Object objects, int index)
{
return ((String[])objects)[index];
}
replace
Overwrites the specified object with the given object.
Syntax
public abstract Object replace(Object objects,
int index,
Object object)
Parameters
objects
|
the objects to use.
|
index
|
the index of the object to replace.
|
object
|
the object to use.
|
Returns
Object
|
the resultant objects.
|
Throws
Example
public Object replace(Object objects, int index, Object object)
{
return ((String[])objects)[index] = object;
}
sort
Sorts the given objects.
Syntax
public abstract Object sort(Object objects)
Parameters
objects
|
the objects to sort.
|
Returns
Object
|
the sorted objects.
|
Throws
Example
String[] sitems = sort(items)
|