List of utility methods to do Array Sort
void | countingSort(int[] array, int low, int high) counting Sort int[] counts = new int[high - low + 1]; for (int x : array) counts[x - low]++; int current = 0; for (int i = 0; i < counts.length; i++) { Arrays.fill(array, current, current + counts[i], i + low); current += counts[i]; |
int[][] | deltaMetricToSortedIndicies(final double[][] deltaMetric) delta Metric To Sorted Indicies class DeltaIndex implements Comparable<DeltaIndex> { public int i, j; public DeltaIndex(int i, int j) { this.i = i; this.j = j; @Override public int compareTo(DeltaIndex o) { ... |
int[] | difference(int[] sorted1, int[] sorted2) difference int[] result = new int[sorted1.length]; int i = 0, j = 0, k = 0; while (i < sorted1.length && j < sorted2.length) { if (sorted1[i] < sorted2[j]) { result[k++] = sorted1[i]; i++; } else if (sorted1[i] > sorted2[j]) { j++; ... |
String | extractFields(String[] items, int[] fields, String delim, boolean sortKeyFields) extract Fields StringBuilder stBld = new StringBuilder(); List<String> keyFields = new ArrayList(); for (int i = 0; i < fields.length; ++i) { keyFields.add(items[fields[i]]); if (sortKeyFields) { Collections.sort(keyFields); boolean first = true; for (String key : keyFields) { if (first) { stBld.append(key); first = false; } else { stBld.append(delim).append(key); return stBld.toString(); |
int | getLeftIndex(float[] sorted, float value) get Left Index int idx = Arrays.binarySearch(sorted, value); int idxMin = idx; while (idxMin > 0 && sorted[idxMin - 1] == sorted[idx]) idxMin--; return idxMin; |
float | getMedianIndex(float[] sorted, float value) get Median Index int idxMin, idxMax; idxMin = Arrays.binarySearch(sorted, value); idxMax = idxMin; while (idxMin > 0 && sorted[idxMin - 1] == sorted[idxMax]) idxMin--; while (idxMax < sorted.length - 1 && sorted[idxMax + 1] == sorted[idxMin]) idxMax++; if (idxMax != idxMin) ... |
int[] | getNewSortedIntArray(int[] codePointArray) get New Sorted Int Array int[] allCodePoints; int codePointCount; if (codePointArray == null || codePointArray.length == 0) throw new IllegalArgumentException("codePointArray is null or has zero length"); codePointCount = codePointArray.length; allCodePoints = new int[codePointCount]; System.arraycopy(codePointArray, 0, allCodePoints, 0, codePointCount); Arrays.sort(allCodePoints); ... |
int[] | getSortedDistinct(int[] values) Sort array & return array with removed repetitive values. if (values.length == 0) return values; Arrays.sort(values); int shift = 0; int i = 0; while (i + shift + 1 < values.length) if (values[i + shift] == values[i + shift + 1]) ++shift; ... |
short[] | intArrayToShortArraySorted(int[] source) int Array To Short Array Sorted short[] result = new short[source.length]; for (int i = 0; i < source.length; i++) { result[i] = (short) source[i]; Arrays.sort(result); return result; |
void | multiQuickSort(int[]... arrays) Multi-sorts the given arrays with the quicksort algorithm. multiQuickSort(0, arrays); |