Skip to content

Commit

Permalink
Bump java, fix issues (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
indy256 authored Dec 27, 2024
1 parent 33fa86f commit 3b3465b
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 25 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push]

jobs:
build-ubuntu-gcc-14:
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
matrix:
config:
Expand All @@ -28,6 +28,8 @@ jobs:
- uses: actions/checkout@v2
- name: install clang
run: |
wget http://mirrors.kernel.org/ubuntu/pool/main/libf/libffi/libffi7_3.3-4_amd64.deb
sudo dpkg -i libffi7_3.3-4_amd64.deb
sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-19 main"
sudo apt-get install clang-19
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
matrix:
config:
- {java-version: 1.8}
- {java-version: 22}
- {java-version: 23}
steps:
- uses: actions/checkout@v2
- name: Set up JDK
Expand Down
6 changes: 2 additions & 4 deletions java/combinatorics/PruferCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public static List<Integer>[] pruferCode2Tree(int[] pruferCode) {
if (degree[v] == 1 && v < ptr) {
leaf = v;
} else {
while (degree[++ptr] != 1)
;
while (degree[++ptr] != 1);
leaf = ptr;
}
}
Expand Down Expand Up @@ -59,8 +58,7 @@ public static int[] tree2PruferCode(List<Integer>[] tree) {
if (degree[next] == 1 && next < ptr) {
leaf = next;
} else {
while (degree[++ptr] != 1)
;
while (degree[++ptr] != 1);
leaf = ptr;
}
}
Expand Down
3 changes: 1 addition & 2 deletions java/combinatorics/RandomGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public static List<Integer>[] getRandomTree(int V, Random rnd) {
public static List<Integer>[] getRandomTree2(int n, Random rnd) {
List<Integer>[] t = Stream.generate(ArrayList::new).limit(n).toArray(List[] ::new);
int[] p = new int[n];
for (int i = 0, j; i < n; j = rnd.nextInt(i + 1), p[i] = p[j], p[j] = i, i++)
; // random permutation
for (int i = 0, j; i < n; j = rnd.nextInt(i + 1), p[i] = p[j], p[j] = i, i++); // random permutation
for (int i = 1; i < n; i++) {
int parent = p[rnd.nextInt(i)];
t[parent].add(p[i]);
Expand Down
3 changes: 1 addition & 2 deletions java/graphs/flows/MaxFlowDinic.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public int maxFlow(int src, int dest) {
int flow = 0;
while (dinicBfs(src, dest)) {
int[] ptr = new int[graph.length];
for (int df; (df = dinicDfs(ptr, dest, src, Integer.MAX_VALUE)) != 0; flow += df)
;
for (int df; (df = dinicDfs(ptr, dest, src, Integer.MAX_VALUE)) != 0; flow += df);
}
return flow;
}
Expand Down
3 changes: 1 addition & 2 deletions java/graphs/matchings/MaxGeneralMatchingRandomized.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ static int rank(int[][] a) {
int n = a.length;
for (int j = 0; j < n; j++) {
int k;
for (k = r; k < n && a[k][j] == 0; k++)
;
for (k = r; k < n && a[k][j] == 0; k++);
if (k == n)
continue;

Expand Down
3 changes: 1 addition & 2 deletions java/strings/SuffixArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public static int[] lcp(int[] sa, CharSequence s) {
for (int i = 0, h = 0; i < n; i++) {
if (rank[i] < n - 1) {
for (int j = sa[rank[i] + 1]; Math.max(i, j) + h < s.length() && s.charAt(i + h) == s.charAt(j + h);
++h)
;
++h);
lcp[rank[i]] = h;
if (h > 0)
--h;
Expand Down
5 changes: 2 additions & 3 deletions java/strings/SuffixArrayDC3.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private static void suffixArray(int[] T, int[] SA, int n, int K) {
if (SA12[t] < n0 ? // different compares for mod 1 and mod 2 suffixes
leq(T[i], R[SA12[t] + n0], T[j], R[j / 3])
: leq(T[i], T[i + 1], R[SA12[t] - n0 + 1], T[j], T[j + 1],
R[j / 3 + n0])) { // suffix from SA12 is smaller
R[j / 3 + n0])) { // suffix from SA12 is smaller
SA[k] = i;
if (++t == n02) // done --- only SA0 suffixes left
for (k++; p < n0; p++, k++) SA[k] = SA0[p];
Expand Down Expand Up @@ -114,8 +114,7 @@ public static int[] lcp(int[] sa, CharSequence s) {
for (int i = 0, h = 0; i < n; i++) {
if (rank[i] < n - 1) {
for (int j = sa[rank[i] + 1]; Math.max(i, j) + h < s.length() && s.charAt(i + h) == s.charAt(j + h);
++h)
;
++h);
lcp[rank[i]] = h;
if (h > 0)
--h;
Expand Down
3 changes: 1 addition & 2 deletions java/structures/LinkCutTreeLca.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ public static void main(String[] args) {
Set<Integer> path = new HashSet<>();
for (; cur != -1; cur = p[cur]) path.add(cur);
cur = v;
for (; cur != -1 && !path.contains(cur); cur = p[cur])
;
for (; cur != -1 && !path.contains(cur); cur = p[cur]);
if (lca != nodes[cur])
throw new RuntimeException();
}
Expand Down
3 changes: 1 addition & 2 deletions java/test/lca/LcaSchieberVishkinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public static void main(String[] args) {
static List<Integer>[] getRandomTree(int n, Random rnd) {
List<Integer>[] t = Stream.generate(ArrayList::new).limit(n).toArray(List[] ::new);
int[] p = new int[n];
for (int i = 0, j; i < n; j = rnd.nextInt(i + 1), p[i] = p[j], p[j] = i, i++)
; // random permutation
for (int i = 0, j; i < n; j = rnd.nextInt(i + 1), p[i] = p[j], p[j] = i, i++); // random permutation
for (int i = 1; i < n; i++) {
int parent = p[rnd.nextInt(i)];
t[parent].add(p[i]);
Expand Down
3 changes: 1 addition & 2 deletions java/test/lca/LcaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public static void main(String[] args) {
static List<Integer>[] getRandomTree(int n, Random rnd) {
List<Integer>[] t = Stream.generate(ArrayList::new).limit(n).toArray(List[] ::new);
int[] p = new int[n];
for (int i = 0, j; i < n; j = rnd.nextInt(i + 1), p[i] = p[j], p[j] = i, i++)
; // random permutation
for (int i = 0, j; i < n; j = rnd.nextInt(i + 1), p[i] = p[j], p[j] = i, i++); // random permutation
for (int i = 1; i < n; i++) {
int parent = p[rnd.nextInt(i)];
t[parent].add(p[i]);
Expand Down
3 changes: 1 addition & 2 deletions java/test/structures/HeavyLightTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ static boolean getPathFromAtoB(List<Integer>[] tree, int a, int b, int p, List<I
static List<Integer>[] getRandomTree(int n, Random rnd) {
List<Integer>[] t = Stream.generate(ArrayList::new).limit(n).toArray(List[] ::new);
int[] p = new int[n];
for (int i = 0, j; i < n; j = rnd.nextInt(i + 1), p[i] = p[j], p[j] = i, i++)
; // random permutation
for (int i = 0, j; i < n; j = rnd.nextInt(i + 1), p[i] = p[j], p[j] = i, i++); // random permutation
for (int i = 1; i < n; i++) {
int parent = p[rnd.nextInt(i)];
t[parent].add(p[i]);
Expand Down

0 comments on commit 3b3465b

Please sign in to comment.