Skip to content

Commit b315b7d

Browse files
authored
style: include WMI_WRONG_MAP_ITERATOR (#5206)
1 parent 440f3ce commit b315b7d

File tree

4 files changed

+9
-25
lines changed

4 files changed

+9
-25
lines changed

spotbugs-exclude.xml

-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@
6868
<Match>
6969
<Bug pattern="IM_BAD_CHECK_FOR_ODD" />
7070
</Match>
71-
<Match>
72-
<Bug pattern="WMI_WRONG_MAP_ITERATOR" />
73-
</Match>
7471
<Match>
7572
<Bug pattern="DM_BOXED_PRIMITIVE_FOR_PARSING" />
7673
</Match>

src/main/java/com/thealgorithms/datastructures/graphs/KahnsAlgorithm.java

+3-16
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@ ArrayList<E> getAdjacents(E v) {
5454
Set<E> getVertices() {
5555
return adj.keySet();
5656
}
57-
58-
/**
59-
* Prints the adjacency list
60-
*/
61-
void printGraph() {
62-
for (E vertex : adj.keySet()) {
63-
System.out.print(vertex + " : ");
64-
for (E adjacent : adj.get(vertex)) {
65-
System.out.print(adjacent + " ");
66-
}
67-
System.out.println();
68-
}
69-
}
7057
}
7158

7259
class TopologicalSort<E extends Comparable<E>> {
@@ -104,9 +91,9 @@ ArrayList<E> topSortOrder() {
10491
calculateInDegree();
10592
Queue<E> q = new LinkedList<E>();
10693

107-
for (E vertex : inDegree.keySet()) {
108-
if (inDegree.get(vertex) == 0) {
109-
q.add(vertex);
94+
for (final var entry : inDegree.entrySet()) {
95+
if (entry.getValue() == 0) {
96+
q.add(entry.getKey());
11097
}
11198
}
11299

src/main/java/com/thealgorithms/datastructures/hashmap/hashing/MajorityElement.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public static List<Integer> majority(int[] nums) {
2727
}
2828
}
2929
List<Integer> majorityElements = new ArrayList<>();
30-
for (int key : numToCount.keySet()) {
31-
if (numToCount.get(key) >= n / 2) {
32-
majorityElements.add(key);
30+
for (final var entry : numToCount.entrySet()) {
31+
if (entry.getValue() >= n / 2) {
32+
majorityElements.add(entry.getKey());
3333
}
3434
}
3535
return majorityElements;

src/main/java/com/thealgorithms/maths/Mode.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public static int[] mode(final int[] numbers) {
3838
int max = Collections.max(count.values());
3939
ArrayList<Integer> modes = new ArrayList<>();
4040

41-
for (int num : count.keySet()) {
42-
if (count.get(num) == max) {
43-
modes.add(num);
41+
for (final var entry : count.entrySet()) {
42+
if (entry.getValue() == max) {
43+
modes.add(entry.getKey());
4444
}
4545
}
4646
return modes.stream().mapToInt(n -> n).toArray();

0 commit comments

Comments
 (0)