New Fixes
- Fixed: ObjectLists Crashed when a null was provided as a Comparator. (Unless the List was Initialized with the ClassType) - Fixed: LinkedLists didn't implement add(Object) - Fixed: Object Collections did have the JavaCollections deprecated as the Constructor. This should only be deprecated for Primitives - Added: Tests with 5k Random names for Object sorting. - Changed: Object Arrays no longer require a Comparable[] it just assumes now that the elements in the Array are Comparable
This commit is contained in:
@@ -387,7 +387,7 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void stableSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES void stableSort(KEY_TYPE[] array) {
|
||||
stableSort(array, 0, array.length);
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ public class ARRAYS
|
||||
* @param length the maxmium size of the array to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void stableSort(KEY_TYPE[] array, int length) {
|
||||
public static GENERIC_KEY_BRACES void stableSort(KEY_TYPE[] array, int length) {
|
||||
stableSort(array, 0, length);
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ public class ARRAYS
|
||||
* @param to where the array should be sorted to
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void stableSort(KEY_TYPE[] array, int from, int to) {
|
||||
public static GENERIC_KEY_BRACES void stableSort(KEY_TYPE[] array, int from, int to) {
|
||||
mergeSort(array, null, from, to);
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void unstableSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES void unstableSort(KEY_TYPE[] array) {
|
||||
unstableSort(array, 0, array.length);
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ public class ARRAYS
|
||||
* @param length the maxmium size of the array to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void unstableSort(KEY_TYPE[] array, int length) {
|
||||
public static GENERIC_KEY_BRACES void unstableSort(KEY_TYPE[] array, int length) {
|
||||
unstableSort(array, 0, length);
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ public class ARRAYS
|
||||
* @param to where the array should be sorted to
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void unstableSort(KEY_TYPE[] array, int from, int to) {
|
||||
public static GENERIC_KEY_BRACES void unstableSort(KEY_TYPE[] array, int from, int to) {
|
||||
quickSort(array, from, to);
|
||||
}
|
||||
|
||||
@@ -536,7 +536,7 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void insertionSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array) {
|
||||
insertionSort(array, 0, array.length);
|
||||
}
|
||||
|
||||
@@ -546,7 +546,7 @@ public class ARRAYS
|
||||
* @param length the maxmium size of the array to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void insertionSort(KEY_TYPE[] array, int length) {
|
||||
public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array, int length) {
|
||||
insertionSort(array, 0, length);
|
||||
}
|
||||
|
||||
@@ -557,7 +557,7 @@ public class ARRAYS
|
||||
* @param to where the array should be sorted to
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void insertionSort(KEY_TYPE[] array, int from, int to) {
|
||||
public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array, int from, int to) {
|
||||
for (int i = from+1;i<to; i++) {
|
||||
KEY_TYPE current = array[i];
|
||||
int j = i - 1;
|
||||
@@ -618,7 +618,7 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void selectionSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array) {
|
||||
selectionSort(array, 0, array.length);
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ public class ARRAYS
|
||||
* @param length the maxmium size of the array to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void selectionSort(KEY_TYPE[] array, int length) {
|
||||
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, int length) {
|
||||
selectionSort(array, 0, length);
|
||||
}
|
||||
|
||||
@@ -639,7 +639,7 @@ public class ARRAYS
|
||||
* @param to where the array should be sorted to
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void selectionSort(KEY_TYPE[] array, int from, int to) {
|
||||
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, int from, int to) {
|
||||
for (int i = from; i < to; i++) {
|
||||
KEY_TYPE min = array[i];
|
||||
int minId = i;
|
||||
@@ -714,7 +714,7 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void mergeSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES void mergeSort(KEY_TYPE[] array) {
|
||||
mergeSort(array, null, 0, array.length);
|
||||
}
|
||||
|
||||
@@ -725,7 +725,7 @@ public class ARRAYS
|
||||
* @param length the maxmium size of the array to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void mergeSort(KEY_TYPE[] array, int length) {
|
||||
public static GENERIC_KEY_BRACES void mergeSort(KEY_TYPE[] array, int length) {
|
||||
mergeSort(array, null, 0, length);
|
||||
}
|
||||
|
||||
@@ -738,7 +738,7 @@ public class ARRAYS
|
||||
* @param to where the array should be sorted to
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void mergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to) {
|
||||
public static GENERIC_KEY_BRACES void mergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to) {
|
||||
if(to - from < BASE_THRESHOLD) {
|
||||
insertionSort(array, from, to);
|
||||
return;
|
||||
@@ -809,7 +809,7 @@ public class ARRAYS
|
||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array) {
|
||||
parallelMergeSort(array, null, 0, array.length);
|
||||
}
|
||||
|
||||
@@ -821,7 +821,7 @@ public class ARRAYS
|
||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array, int length) {
|
||||
public static GENERIC_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array, int length) {
|
||||
parallelMergeSort(array, null, 0, length);
|
||||
}
|
||||
|
||||
@@ -835,7 +835,7 @@ public class ARRAYS
|
||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to) {
|
||||
public static GENERIC_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to) {
|
||||
if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) {
|
||||
SanityChecks.invokeTask(new MergeSortActionBRACES(array, supp, from, to));
|
||||
return;
|
||||
@@ -923,7 +923,7 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array) {
|
||||
memFreeMergeSort(array, 0, array.length);
|
||||
}
|
||||
|
||||
@@ -937,7 +937,7 @@ public class ARRAYS
|
||||
* @param length the maxmium size of the array to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array, int length) {
|
||||
public static GENERIC_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array, int length) {
|
||||
memFreeMergeSort(array, 0, length);
|
||||
}
|
||||
|
||||
@@ -952,7 +952,7 @@ public class ARRAYS
|
||||
* @param to where the array should be sorted to
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array, int from, int to) {
|
||||
public static GENERIC_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array, int from, int to) {
|
||||
if(to - from < BASE_THRESHOLD) {
|
||||
insertionSort(array, from, to);
|
||||
return;
|
||||
@@ -1053,7 +1053,7 @@ public class ARRAYS
|
||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array) {
|
||||
parallelMemFreeMergeSort(array, 0, array.length);
|
||||
}
|
||||
|
||||
@@ -1068,7 +1068,7 @@ public class ARRAYS
|
||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int length) {
|
||||
public static GENERIC_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int length) {
|
||||
parallelMemFreeMergeSort(array, 0, length);
|
||||
}
|
||||
|
||||
@@ -1084,7 +1084,7 @@ public class ARRAYS
|
||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int from, int to) {
|
||||
public static GENERIC_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int from, int to) {
|
||||
if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) {
|
||||
SanityChecks.invokeTask(new MemFreeMergeSortActionBRACES(array, from, to));
|
||||
return;
|
||||
@@ -1158,7 +1158,7 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void quickSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES void quickSort(KEY_TYPE[] array) {
|
||||
quickSort(array, 0, array.length);
|
||||
}
|
||||
|
||||
@@ -1170,7 +1170,7 @@ public class ARRAYS
|
||||
* @param length the maxmium size of the array to be sorted
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void quickSort(KEY_TYPE[] array, int length) {
|
||||
public static GENERIC_KEY_BRACES void quickSort(KEY_TYPE[] array, int length) {
|
||||
quickSort(array, 0, length);
|
||||
}
|
||||
|
||||
@@ -1183,7 +1183,7 @@ public class ARRAYS
|
||||
* @param to where the array should be sorted to
|
||||
* @ArrayType(T)
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void quickSort(KEY_TYPE[] array, int from, int to) {
|
||||
public static GENERIC_KEY_BRACES void quickSort(KEY_TYPE[] array, int from, int to) {
|
||||
int length = to - from;
|
||||
if(length <= 0) return;
|
||||
if(length < BASE_THRESHOLD) {
|
||||
@@ -1261,7 +1261,7 @@ public class ARRAYS
|
||||
* @ArrayType(T)
|
||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array) {
|
||||
parallelQuickSort(array, 0, array.length);
|
||||
}
|
||||
|
||||
@@ -1274,7 +1274,7 @@ public class ARRAYS
|
||||
* @ArrayType(T)
|
||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array, int length) {
|
||||
public static GENERIC_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array, int length) {
|
||||
parallelQuickSort(array, 0, length);
|
||||
}
|
||||
|
||||
@@ -1288,7 +1288,7 @@ public class ARRAYS
|
||||
* @ArrayType(T)
|
||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
||||
*/
|
||||
public static COMPAREABLE_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array, int from, int to) {
|
||||
public static GENERIC_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array, int from, int to) {
|
||||
if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) {
|
||||
SanityChecks.invokeTask(new QuickSortActionBRACES(array, from, to));
|
||||
return;
|
||||
@@ -1315,15 +1315,15 @@ public class ARRAYS
|
||||
return comp.compare(data[a], data[b]) < 0 ? (comp.compare(data[b], data[c]) < 0 ? b : comp.compare(data[a], data[c]) < 0 ? c : a) : (comp.compare(data[b], data[c]) > 0 ? b : comp.compare(data[a], data[c]) > 0 ? c : a);
|
||||
}
|
||||
|
||||
static COMPAREABLE_KEY_BRACES int subMedium(KEY_TYPE[] data, int a, int b, int c, int length) {
|
||||
static GENERIC_KEY_BRACES int subMedium(KEY_TYPE[] data, int a, int b, int c, int length) {
|
||||
return medium(data, medium(data, a, a + length, a + (length * 2)), medium(data, b - length, b, b + length), medium(data, c - (length * 2), c - length, c));
|
||||
}
|
||||
|
||||
static COMPAREABLE_KEY_BRACES int medium(KEY_TYPE[] data, int a, int b, int c) {
|
||||
static GENERIC_KEY_BRACES int medium(KEY_TYPE[] data, int a, int b, int c) {
|
||||
return COMPAREABLE_TO_KEY(data[a], data[b]) < 0 ? (COMPAREABLE_TO_KEY(data[b], data[c]) < 0 ? b : COMPAREABLE_TO_KEY(data[a], data[c]) < 0 ? c : a) : (COMPAREABLE_TO_KEY(data[b], data[c]) > 0 ? b : COMPAREABLE_TO_KEY(data[a], data[c]) > 0 ? c : a);
|
||||
}
|
||||
|
||||
static class QuickSortAction KEY_COMPAREABLE_TYPE extends RecursiveAction {
|
||||
static class QuickSortAction KEY_GENERIC_TYPE extends RecursiveAction {
|
||||
private static final long serialVersionUID = 0L;
|
||||
KEY_TYPE[] array;
|
||||
int from;
|
||||
@@ -1407,7 +1407,7 @@ public class ARRAYS
|
||||
}
|
||||
}
|
||||
|
||||
static class MergeSortAction KEY_COMPAREABLE_TYPE extends RecursiveAction {
|
||||
static class MergeSortAction KEY_GENERIC_TYPE extends RecursiveAction {
|
||||
private static final long serialVersionUID = 0L;
|
||||
KEY_TYPE[] array;
|
||||
KEY_TYPE[] supp;
|
||||
@@ -1483,7 +1483,7 @@ public class ARRAYS
|
||||
}
|
||||
}
|
||||
|
||||
static class MemFreeMergeSortAction KEY_COMPAREABLE_TYPE extends RecursiveAction {
|
||||
static class MemFreeMergeSortAction KEY_GENERIC_TYPE extends RecursiveAction {
|
||||
private static final long serialVersionUID = 0L;
|
||||
KEY_TYPE[] array;
|
||||
int from;
|
||||
|
||||
Reference in New Issue
Block a user