Skip to content

Commit 3e69ba3

Browse files
committed
Removed dead code.
1 parent a22f821 commit 3e69ba3

File tree

3 files changed

+24
-48
lines changed

3 files changed

+24
-48
lines changed

src/main/java/io/github/coderodde/util/ParallelRadixSort.java

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -899,49 +899,6 @@ private static void radixSortImpl(long[] source,
899899
}
900900
}
901901

902-
/**
903-
* Merges the runs
904-
* {@code source[leftIndex], ..., source[leftIndexBound - 1]} and
905-
* {@code source[leftBoundIndex, ..., source[rightIndexBound - 1]} into one
906-
* sorted run.
907-
*
908-
* @param source the source array.
909-
* @param target the target array.
910-
* @param leftIndex the lowest index of the left run to merge.
911-
* @param leftIndexBound the lowest index of the right run to merge.
912-
* @param rightIndexBound the one past last index of the right run to merge.
913-
* @param targetIndex the starting index of the resulting, merged run.
914-
*/
915-
private static void merge(int[] source,
916-
int[] target,
917-
int leftIndex,
918-
int leftIndexBound,
919-
int rightIndexBound,
920-
int targetIndex) {
921-
int rightIndex = leftIndexBound;
922-
923-
while (leftIndex != leftIndexBound && rightIndex != rightIndexBound) {
924-
target[targetIndex++] =
925-
source[leftIndex] < source[rightIndex] ?
926-
source[leftIndex++] :
927-
source[rightIndex++];
928-
}
929-
930-
System.arraycopy(
931-
source,
932-
leftIndex,
933-
target,
934-
targetIndex,
935-
leftIndexBound - leftIndex);
936-
937-
System.arraycopy(
938-
source,
939-
rightIndex,
940-
target,
941-
targetIndex,
942-
rightIndexBound - rightIndex);
943-
}
944-
945902
/**
946903
* Returns the bucket index of the {@code element} at the top-most recursion
947904
* level.

src/main/java/io/github/coderodde/util/ParallelRadixSortBenchmark.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ public final class ParallelRadixSortBenchmark {
1212
private static final int MAXIMUM_SKIP_LAST_ELEMENTS = 1711;
1313

1414
public static void main(String[] args) {
15-
System.out.println("Warming up benchmark 1...");
1615
benchmark(false);
17-
System.out.println("Warming up benchmark 2...");
1816
benchmark2(false);
19-
System.out.println("Benchmarking 1...");
17+
2018
benchmark(true);
21-
System.out.println("Benchmarking 2...");
2219
benchmark2(true);
20+
2321
System.out.println("Benchmark done!");
2422
}
2523

2624
private static void benchmark(boolean print) {
25+
System.out.println(
26+
"<<< " +
27+
(print ? "Benchmarking" : "Warming")
28+
+ " on sorted data >>>");
29+
2730
Random random = new Random();
2831
long totalDuration1 = 0L;
2932
long totalDuration2 = 0L;
@@ -34,7 +37,7 @@ private static void benchmark(boolean print) {
3437
MINIMUM_ARRAY_SIZE +-
3538
random.nextInt(MAXIMUM_ARRAY_SIZE - MINIMUM_ARRAY_SIZE + 1);
3639

37-
long[] array1 = Utils.createRandomLongArray(arrayLength, random);
40+
long[] array1 = Utils.createSortedLongArray(arrayLength);
3841
long[] array2 = array1.clone();
3942

4043
int fromIndex = random.nextInt(MAXIMUM_FROM_INDEX + 1);
@@ -76,6 +79,11 @@ private static void benchmark(boolean print) {
7679
}
7780

7881
private static void benchmark2(boolean print) {
82+
System.out.println(
83+
"<<< " +
84+
(print ? "Benchmarking" : "Warming")
85+
+ " on random data >>>");
86+
7987
Random random = new Random();
8088
long totalDuration1 = 0L;
8189
long totalDuration2 = 0L;

src/main/java/io/github/coderodde/util/Utils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,15 @@ public static long[] createRandomLongArray(int size, Random random) {
1414

1515
return a;
1616
}
17+
18+
public static long[] createSortedLongArray(int size) {
19+
20+
long[] a = new long[size];
21+
22+
for (int i = 0; i < size; i++) {
23+
a[i] = 0L;
24+
}
25+
26+
return a;
27+
}
1728
}

0 commit comments

Comments
 (0)