Package HAL.Interfaces
Interface Sortable
-
public interface Sortable
allows for the QuickSort function to be used to sort the object
-
-
Method Summary
Modifier and Type Method Description default <T extends Sortable>
int_Partition(T sortMe, int lo, int hi, boolean greatestToLeast)
default <T extends Sortable>
void_SortHelper(T sortMe, int lo, int hi, boolean greatestToLeast)
double
Compare(int iFirst, int iSecond)
should return a positive number if first > second, negative if second > first, 0 if equalint
Length()
should return the number of objects to sort in the data structuredefault <T extends Sortable>
voidQuickSort(boolean greatestToLeast)
Runs quicksort on an object that implements Sortablevoid
Swap(int iFirst, int iSecond)
should swap the objects at these indices so that they switch places in their data structure
-
-
-
Method Detail
-
Compare
double Compare(int iFirst, int iSecond)
should return a positive number if first > second, negative if second > first, 0 if equal- Parameters:
iFirst
- the index of the first object to compareiSecond
- the index of the second object to compare
-
Swap
void Swap(int iFirst, int iSecond)
should swap the objects at these indices so that they switch places in their data structure- Parameters:
iFirst
- the index of the first object to compareiSecond
- the index of the second object to compare
-
Length
int Length()
should return the number of objects to sort in the data structure
-
QuickSort
default <T extends Sortable> void QuickSort(boolean greatestToLeast)
Runs quicksort on an object that implements Sortable- Parameters:
greatestToLeast
- if true, sorting will be form greatest to least, otherwise will be least to greatest
-
_SortHelper
default <T extends Sortable> void _SortHelper(T sortMe, int lo, int hi, boolean greatestToLeast)
-
_Partition
default <T extends Sortable> int _Partition(T sortMe, int lo, int hi, boolean greatestToLeast)
-
-