Skip to content

Commit

Permalink
[skip ci] Shift some things around
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Nov 2, 2021
1 parent 56b8175 commit 73d11be
Showing 1 changed file with 7 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,9 @@ else if(grailBufferType == 2) {
long begin;
long time;

if(algorithm == 0) {
HolyGrailSort<GrailPair> grail = new HolyGrailSort<>(test);

GrailPair[] buffer = null;
int bufferLen = 0;

GrailPair[] buffer = null;
int bufferLen = 0;
if(algorithm == 0 || algorithm == 1) {
// Holy Grail Sort with static buffer
if(grailBufferType == 1) {
buffer = (GrailPair[]) Array.newInstance(this.keyArray.getClass().getComponentType(), HolyGrailSort.STATIC_EXT_BUFFER_LEN);
Expand All @@ -234,30 +231,17 @@ else if(grailBufferType == 2) {
}
buffer = (GrailPair[]) Array.newInstance(this.keyArray.getClass().getComponentType(), bufferLen);
}
}

if(algorithm == 0) {
HolyGrailSort<GrailPair> grail = new HolyGrailSort<>(test);

begin = System.nanoTime();
grail.commonSort(this.keyArray, start, length, buffer, bufferLen);
time = System.nanoTime() - begin;
} else if (algorithm == 1) {
RewrittenGrailsort<GrailPair> grail = new RewrittenGrailsort<>(test);

GrailPair[] buffer = null;
int bufferLen = 0;

// Holy Grail Sort with static buffer
if(grailBufferType == 1) {
buffer = (GrailPair[]) Array.newInstance(this.keyArray.getClass().getComponentType(), HolyGrailSort.STATIC_EXT_BUFFER_LEN);
bufferLen = HolyGrailSort.STATIC_EXT_BUFFER_LEN;
}
// Holy Grail Sort with dynamic buffer
else if(grailBufferType == 2) {
bufferLen = 1;
while((bufferLen * bufferLen) < length) {
bufferLen *= 2;
}
buffer = (GrailPair[]) Array.newInstance(this.keyArray.getClass().getComponentType(), bufferLen);
}

begin = System.nanoTime();
grail.grailCommonSort(this.keyArray, start, length, buffer, bufferLen);
time = System.nanoTime() - begin;
Expand Down

0 comments on commit 73d11be

Please sign in to comment.