Skip to content

Commit

Permalink
forgor smth
Browse files Browse the repository at this point in the history
  • Loading branch information
smaybius committed May 22, 2024
1 parent 0b6295f commit 712a174
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 444 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: mvn clean install
- name: Upload artifact
uses: actions/upload-artifact@v2
if: ${{ matrix.java == 8 && matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.java == 17 && matrix.os == 'ubuntu-latest' }}
with:
name: standalone-jar
path: target/ArrayV-*.jar
382 changes: 0 additions & 382 deletions .vscode/java-formatter.xml

This file was deleted.

5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"org.graalvm.*",
"io.micrometer.shaded.*"
],
"java.format.settings.url": "./eclipse-java-google-style.xml"
"java.format.settings.url": ".vscode/java-formatter.xml",
"[java]": {
"editor.tabSize": 2
}
}
9 changes: 5 additions & 4 deletions src/main/java/io/github/arrayv/groovyapi/GroovyLocals.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.github.arrayv.groovyapi;

import java.util.Map;

import org.codehaus.groovy.runtime.MethodClosure;

import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import groovy.transform.stc.ClosureParams;
Expand All @@ -13,9 +17,6 @@
import io.github.arrayv.sortdata.SortNameType;
import io.github.arrayv.sorts.templates.Sort;
import io.github.arrayv.utils.Sounds;
import org.codehaus.groovy.runtime.MethodClosure;

import java.util.Map;

/**
* This class defines methods and properties directly accessible from within
Expand Down Expand Up @@ -98,7 +99,7 @@ public static SortInfo getSort(String name, SortNameType nameType) {
*/
public static SortInfo newSort(
@ClosureParams(value = FromAbstractTypeMethods.class, options = {
"io.github.arrayv.groovyapi.GroovyLocals$SortFunctionSignatures" }) Closure<?> sort,
"io.github.arrayv.groovyapi.GroovyLocals$SortFunctionSignatures" }) Closure<?> sort,
@DelegatesTo(SortInfo.Builder.class) Closure<?> metadata) {
switch (sort.getMaximumNumberOfParameters()) {
case 2:
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/github/arrayv/sorts/templates/Sort.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ protected Sort(ArrayVisualizer arrayVisualizer) {
private void initDeprecatedMetadataTable() {
if (deprecatedMetadataTable != null)
return;
deprecatedMetadataTable = new Object[] {
true, "", "", "", "", false, false, false, 0, null, 0
deprecatedMetadataTable = new Object[] { true, "", "", "", "", false, false, false, 0, null, 0
};
}

Expand Down
28 changes: 14 additions & 14 deletions src/main/java/io/github/arrayv/utils/PerlinNoise.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
// MASSIVE thanks to https://github.com/keijiro/PerlinNoise
public final class PerlinNoise {
private static final int[] PERM = {
151, 160, 137, 91, 90, 15,
131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,
190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,
88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,
77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244,
102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196,
135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123,
5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42,
223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9,
129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228,
251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107,
49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254,
138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180,
151
151, 160, 137, 91, 90, 15,
131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,
190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,
88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,
77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244,
102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196,
135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123,
5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42,
223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9,
129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228,
251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107,
49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254,
138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180,
151
};

private PerlinNoise() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/arrayv/utils/Range.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.arrayv.utils;

public final class Range {
public int start;
public int end;
private int start;
private int end;

public Range(int start1, int end1) {
this.start = start1;
Expand Down
76 changes: 38 additions & 38 deletions src/main/java/io/github/arrayv/utils/Searches.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,70 @@
import io.github.arrayv.main.ArrayVisualizer;

public final class Searches {
private static final Delays Delays = ArrayVisualizer.getInstance().getDelays();
private static final Highlights Highlights = ArrayVisualizer.getInstance().getHighlights();
private static final Reads Reads = ArrayVisualizer.getInstance().getReads();
private static final Writes Writes = ArrayVisualizer.getInstance().getWrites();
private static final Delays DELAYS = ArrayVisualizer.getInstance().getDelays();
private static final Highlights HIGHLIGHTS = ArrayVisualizer.getInstance().getHighlights();
private static final Reads READS = ArrayVisualizer.getInstance().getReads();
private static final Writes WRITES = ArrayVisualizer.getInstance().getWrites();

private Searches() {
}

public static int leftBinSearch(int[] array, int start, int end, int val, double delay) {
while (start < end) {
int mid = start + (end - start) / 2;
Highlights.markArray(1, start);
Highlights.markArray(2, mid);
Highlights.markArray(3, end);
Delays.sleep(delay);
if (Reads.compareValues(val, array[mid]) <= 0)
HIGHLIGHTS.markArray(1, start);
HIGHLIGHTS.markArray(2, mid);
HIGHLIGHTS.markArray(3, end);
DELAYS.sleep(delay);
if (READS.compareValues(val, array[mid]) <= 0)
end = mid;
else
start = mid + 1;
}
Highlights.clearAllMarks();
HIGHLIGHTS.clearAllMarks();
return start;
}

public static int rightBinSearch(int[] array, int start, int end, int val, double delay) {
while (start < end) {
int mid = start + (end - start) / 2;
Highlights.markArray(1, start);
Highlights.markArray(2, mid);
Highlights.markArray(3, end);
HIGHLIGHTS.markArray(1, start);
HIGHLIGHTS.markArray(2, mid);
HIGHLIGHTS.markArray(3, end);

Delays.sleep(delay);
if (Reads.compareValues(val, array[mid]) < 0)
DELAYS.sleep(delay);
if (READS.compareValues(val, array[mid]) < 0)
end = mid;
else
start = mid + 1;
}
Highlights.clearAllMarks();
HIGHLIGHTS.clearAllMarks();
return start;
}

public static int leftExpSearch(int[] array, int start, int end, int val, double delay) {
int position = 1;
Highlights.markArray(1, start);
Highlights.markArray(2, end);
while (start - 1 + position < end && Reads.compareValues(val, array[start - 1 + position]) > 0) {
Highlights.markArray(3, start - 1 + position);
Highlights.markArray(4, position);
Delays.sleep(delay);
HIGHLIGHTS.markArray(1, start);
HIGHLIGHTS.markArray(2, end);
while (start - 1 + position < end && READS.compareValues(val, array[start - 1 + position]) > 0) {
HIGHLIGHTS.markArray(3, start - 1 + position);
HIGHLIGHTS.markArray(4, position);
DELAYS.sleep(delay);
position *= 2;
}
Highlights.clearAllMarks();
HIGHLIGHTS.clearAllMarks();
return leftBinSearch(array, start + position / 2, Math.min(end, start - 1 + position), val, delay);
}

public static int rightExpSearch(int[] array, int start, int end, int val, double delay) {
int position = 1;
while (end - position >= start && Reads.compareValues(val, array[end - position]) < 0) {
Highlights.markArray(3, end - position);
Highlights.markArray(4, position);
Delays.sleep(delay);
while (end - position >= start && READS.compareValues(val, array[end - position]) < 0) {
HIGHLIGHTS.markArray(3, end - position);
HIGHLIGHTS.markArray(4, position);
DELAYS.sleep(delay);
position *= 2;
}
Highlights.clearAllMarks();
HIGHLIGHTS.clearAllMarks();
return rightBinSearch(array, Math.max(start, end - position + 1), end - position / 2, val, delay);
}

Expand All @@ -76,34 +76,34 @@ public static int rightIntpSearch(int[] array, int start, int end, int val, doub
int max = array[end - 1];

if (min == max) {
Highlights.markArray(2, start);
Highlights.markArray(3, end);
Delays.sleep(searchdelay);
HIGHLIGHTS.markArray(2, start);
HIGHLIGHTS.markArray(3, end);
DELAYS.sleep(searchdelay);

if (Reads.compareValues(val, min) < 0)
if (READS.compareValues(val, min) < 0)
end = start;
else
start = end;
} else {
int m = start
+ (int) ((end - start - 1) * ((double) Math.max(0, Math.min(val, max) - min) / (max - min)));
Highlights.markArray(2, m);
Delays.sleep(searchdelay);
HIGHLIGHTS.markArray(2, m);
DELAYS.sleep(searchdelay);

if (Reads.compareValues(val, array[m]) < 0)
if (READS.compareValues(val, array[m]) < 0)
end = m;
else
start = m + 1;
}
}
Highlights.clearAllMarks();
HIGHLIGHTS.clearAllMarks();
return start;
}

public static void insertTo(int[] array, int start, int end, double delay, boolean auxwrite) {
int temp = array[start];
while (start > end)
Writes.write(array, start, array[--start], delay / 2, true, auxwrite);
Writes.write(array, end, temp, delay / 2, true, auxwrite);
WRITES.write(array, start, array[--start], delay / 2, true, auxwrite);
WRITES.write(array, end, temp, delay / 2, true, auxwrite);
}
}

0 comments on commit 712a174

Please sign in to comment.