Skip to content

Commit b813d2d

Browse files
committed
Merge branch 'feature/improve_code_look' of https://github.com/rozi26/java_algo_fork1
2 parents 2764454 + 8ecf1ff commit b813d2d

16 files changed

+21
-31
lines changed

.github/dependabot.yml

+5
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ updates:
1010
directory: "/.github/workflows/"
1111
schedule:
1212
interval: "daily"
13+
14+
- package-ecosystem: "maven"
15+
directory: "/"
16+
schedule:
17+
interval: "daily"
1318
...

.gitpod.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM gitpod/workspace-java-17:2024-04-16-12-16-24
1+
FROM gitpod/workspace-java-17:2024-04-29-23-03-42
22

33
ENV LLVM_SCRIPT="tmp_llvm.sh"
44

checkstyle.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147

148148
<!-- Modifier Checks -->
149149
<!-- See https://checkstyle.org/checks/modifier/index.html -->
150-
<!-- TODO <module name="ModifierOrder"/> -->
150+
<module name="ModifierOrder"/>
151151
<!-- TODO <module name="RedundantModifier"/> -->
152152

153153
<!-- Checks for blocks. You know, those {}'s -->

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<plugin>
7272
<groupId>org.apache.maven.plugins</groupId>
7373
<artifactId>maven-compiler-plugin</artifactId>
74-
<version>3.10.1</version>
74+
<version>3.13.0</version>
7575
<configuration>
7676
<source>17</source>
7777
<target>17</target>
@@ -110,7 +110,7 @@
110110
<dependency>
111111
<groupId>com.puppycrawl.tools</groupId>
112112
<artifactId>checkstyle</artifactId>
113-
<version>9.3</version>
113+
<version>10.16.0</version>
114114
</dependency>
115115
</dependencies>
116116
</plugin>

spotbugs-exclude.xml

-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
<Match>
99
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
1010
</Match>
11-
<Match>
12-
<Bug pattern="IM_AVERAGE_COMPUTATION_COULD_OVERFLOW" />
13-
</Match>
1411
<Match>
1512
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
1613
</Match>
@@ -20,9 +17,6 @@
2017
<Match>
2118
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
2219
</Match>
23-
<Match>
24-
<Bug pattern="UC_USELESS_OBJECT" />
25-
</Match>
2620
<Match>
2721
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
2822
</Match>

src/main/java/com/thealgorithms/bitmanipulation/HighestSetBit.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public final class HighestSetBit {
1212
private HighestSetBit() {
1313
}
1414

15-
public final static Optional<Integer> findHighestSetBit(int num) {
15+
public static Optional<Integer> findHighestSetBit(int num) {
1616
if (num < 0) {
1717
throw new IllegalArgumentException("Input cannot be negative");
1818
}

src/main/java/com/thealgorithms/dynamicprogramming/LongestIncreasingSubsequence.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private static int binarySearchBetween(int[] t, int end, int key) {
9797
return end + 1;
9898
}
9999
while (left < right - 1) {
100-
int middle = (left + right) / 2;
100+
final int middle = (left + right) >>> 1;
101101
if (t[middle] < key) {
102102
left = middle;
103103
} else {

src/main/java/com/thealgorithms/misc/RangeInSortedArray.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void alteredBinSearch(int[] nums, int key, int left, int right, in
2626
if (left > right) {
2727
return;
2828
}
29-
int mid = (left + right) / 2;
29+
int mid = (left + right) >>> 1;
3030
if (nums[mid] > key) {
3131
alteredBinSearch(nums, key, left, mid - 1, range, goLeft);
3232
} else if (nums[mid] < key) {
@@ -52,7 +52,7 @@ public static void alteredBinSearch(int[] nums, int key, int left, int right, in
5252
// of 'key'
5353
public static void alteredBinSearchIter(int[] nums, int key, int left, int right, int[] range, boolean goLeft) {
5454
while (left <= right) {
55-
int mid = (left + right) / 2;
55+
final int mid = (left + right) >>> 1;
5656
if (nums[mid] > key) {
5757
right = mid - 1;
5858
} else if (nums[mid] < key) {
@@ -84,7 +84,7 @@ public static int getCountLessThan(int[] nums, int key) {
8484
public static int getLessThan(int[] nums, int key, int left, int right) {
8585
int count = 0;
8686
while (left <= right) {
87-
int mid = (left + right) / 2;
87+
final int mid = (left + right) >>> 1;
8888
if (nums[mid] > key) {
8989
right = mid - 1;
9090
} else if (nums[mid] <= key) {

src/main/java/com/thealgorithms/others/CountWords.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @author Marcus
55
*/
6-
final public class CountWords {
6+
public final class CountWords {
77
private CountWords() {
88
}
99

src/main/java/com/thealgorithms/others/EulersFunction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @brief utility class for <a href="https://en.wikipedia.org/wiki/Euler%27s_totient_function">Euler's totient function</a>
55
*/
6-
final public class EulersFunction {
6+
public final class EulersFunction {
77
private EulersFunction() {
88
}
99

src/main/java/com/thealgorithms/others/LowestBasePalindrome.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @brief Class for finding the lowest base in which a given integer is a palindrome.
77
cf. https://oeis.org/A016026
88
*/
9-
final public class LowestBasePalindrome {
9+
public final class LowestBasePalindrome {
1010
private LowestBasePalindrome() {
1111
}
1212

src/main/java/com/thealgorithms/others/SieveOfEratosthenes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* @brief utility class implementing <a href="https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">Sieve of Eratosthenes</a>
77
*/
8-
final public class SieveOfEratosthenes {
8+
public final class SieveOfEratosthenes {
99
private SieveOfEratosthenes() {
1010
}
1111

src/main/java/com/thealgorithms/others/cn/HammingDistance.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.thealgorithms.others.cn;
22

3-
final public class HammingDistance {
3+
public final class HammingDistance {
44
private HammingDistance() {
55
}
66

src/main/java/com/thealgorithms/sorts/BinaryInsertionSort.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public int[] binaryInsertSort(int[] array) {
1010
int high = i - 1;
1111

1212
while (low <= high) {
13-
int mid = (low + high) / 2;
13+
final int mid = (low + high) >>> 1;
1414
if (temp < array[mid]) {
1515
high = mid - 1;
1616
} else {

src/main/java/com/thealgorithms/sorts/MergeSortRecursive.java

-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.thealgorithms.sorts;
22

33
import java.util.ArrayList;
4-
import java.util.Arrays;
54
import java.util.List;
65

76
public class MergeSortRecursive {
@@ -59,11 +58,3 @@ private static List<Integer> sort(List<Integer> unsortedA, List<Integer> unsorte
5958
}
6059
}
6160
}
62-
63-
class App {
64-
65-
public static void main(String[] args) {
66-
MergeSortRecursive sort = new MergeSortRecursive(new ArrayList<>(Arrays.asList(4, 3, 1, 8, 5, 10, 0, 1, 4, 11, 8, 9)));
67-
sort.mergeSort();
68-
}
69-
}

src/main/java/com/thealgorithms/sorts/SlowSort.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private <T extends Comparable<T>> void sort(T[] array, int i, int j) {
1616
if (SortUtils.greaterOrEqual(i, j)) {
1717
return;
1818
}
19-
int m = (i + j) / 2;
19+
final int m = (i + j) >>> 1;
2020
sort(array, i, m);
2121
sort(array, m + 1, j);
2222
if (SortUtils.less(array[j], array[m])) {

0 commit comments

Comments
 (0)