Skip to content

Commit cfcd052

Browse files
committed
Add needed data structures.
1 parent db047cc commit cfcd052

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,21 @@ private static void parallelRadixSortImpl(
328328
ex);
329329
}
330330
}
331+
332+
if (recursionDepth == DEEPEST_RECURSION_DEPTH) {
333+
// Nowhere to recur, all bytes are processed. Return.
334+
return;
335+
}
336+
337+
ListOfBucketKeyLists listOfBucketKeyLists =
338+
new ListOfBucketKeyLists(spawnDegree);
339+
340+
for (int i = 0; i != spawnDegree; i++) {
341+
BucketKeyList bucketKeyList =
342+
new BucketKeyList(numberOfNonemptyBuckets);
343+
344+
listOfBucketKeyLists.addBucketKeyList(bucketKeyList);
345+
}
331346
}
332347

333348
private static void rangeCheck(
@@ -703,4 +718,25 @@ int size() {
703718
return size;
704719
}
705720
}
721+
722+
private static final class ListOfBucketKeyLists {
723+
private final BucketKeyList[] lists;
724+
private int size;
725+
726+
ListOfBucketKeyLists(int capacity) {
727+
this.lists = new BucketKeyList[capacity];
728+
}
729+
730+
void addBucketKeyList(BucketKeyList bucketKeyList) {
731+
this.lists[this.size++] = bucketKeyList;
732+
}
733+
734+
BucketKeyList getBucketKeyList(int index) {
735+
return this.lists[index];
736+
}
737+
738+
int size() {
739+
return size;
740+
}
741+
}
706742
}

0 commit comments

Comments
 (0)