All Packages Class Hierarchy This Package Previous Next Index
Class spec.harness.QuickSort
spec.harness.QuickSort
- public class QuickSort
This class implements the quick sort algorithm. Given the array of
strings, this class provides the functions to sort them
-
QuickSort()
-
-
compare(String, String)
- Compares two strings lexicographically.
-
sort(String)
- Sorts the sub strings (which are seperated by "\n") in a string
-
sort(String, boolean)
- Tokenizes the given string by looking for '\n' and sorts the resulting string
array.
-
sort(String[])
- Sorts the string array passed
-
startSort(String[])
- Starts the sorting of strings.
QuickSort
public QuickSort()
startSort
public void startSort(String userArray[])
- Starts the sorting of strings.
- Parameters:
- userArray - Array of String objects to be sorted
compare
public int compare(String a,
String b)
- Compares two strings lexicographically. The comparison is based on the
Unicode value of each character in the strings.
- Parameters:
- a - First string
- b - Second string
- Returns:
- the value 0 if the argument string is equal to this string; a value
less than 0 if this string is lexicographically less than the string argument;
and a value greater than 0 if this string is lexicographically greater than
the string argument.
sort
public static String[] sort(String args[])
- Sorts the string array passed
- Parameters:
- args - Array of strings to be sorted
sort
public static String sort(String text,
boolean comments)
- Tokenizes the given string by looking for '\n' and sorts the resulting string
array. Constructs back the string object with the sorted entries and returns
the resultant string object.
- Parameters:
- text - Text to be sorted
- comments - Flag indicating whether the resulting string should have
line feeds or not
sort
public static String sort(String text)
- Sorts the sub strings (which are seperated by "\n") in a string
All Packages Class Hierarchy This Package Previous Next Index