style: include WMI_WRONG_MAP_ITERATOR (#5206)

This commit is contained in:
Piotr Idzik
2024-06-05 20:52:12 +02:00
committed by GitHub
parent 440f3ce18b
commit b315b7d578
4 changed files with 9 additions and 25 deletions

View File

@ -68,9 +68,6 @@
<Match> <Match>
<Bug pattern="IM_BAD_CHECK_FOR_ODD" /> <Bug pattern="IM_BAD_CHECK_FOR_ODD" />
</Match> </Match>
<Match>
<Bug pattern="WMI_WRONG_MAP_ITERATOR" />
</Match>
<Match> <Match>
<Bug pattern="DM_BOXED_PRIMITIVE_FOR_PARSING" /> <Bug pattern="DM_BOXED_PRIMITIVE_FOR_PARSING" />
</Match> </Match>

View File

@ -54,19 +54,6 @@ class AdjacencyList<E extends Comparable<E>> {
Set<E> getVertices() { Set<E> getVertices() {
return adj.keySet(); return adj.keySet();
} }
/**
* Prints the adjacency list
*/
void printGraph() {
for (E vertex : adj.keySet()) {
System.out.print(vertex + " : ");
for (E adjacent : adj.get(vertex)) {
System.out.print(adjacent + " ");
}
System.out.println();
}
}
} }
class TopologicalSort<E extends Comparable<E>> { class TopologicalSort<E extends Comparable<E>> {
@ -104,9 +91,9 @@ class TopologicalSort<E extends Comparable<E>> {
calculateInDegree(); calculateInDegree();
Queue<E> q = new LinkedList<E>(); Queue<E> q = new LinkedList<E>();
for (E vertex : inDegree.keySet()) { for (final var entry : inDegree.entrySet()) {
if (inDegree.get(vertex) == 0) { if (entry.getValue() == 0) {
q.add(vertex); q.add(entry.getKey());
} }
} }

View File

@ -27,9 +27,9 @@ public final class MajorityElement {
} }
} }
List<Integer> majorityElements = new ArrayList<>(); List<Integer> majorityElements = new ArrayList<>();
for (int key : numToCount.keySet()) { for (final var entry : numToCount.entrySet()) {
if (numToCount.get(key) >= n / 2) { if (entry.getValue() >= n / 2) {
majorityElements.add(key); majorityElements.add(entry.getKey());
} }
} }
return majorityElements; return majorityElements;

View File

@ -38,9 +38,9 @@ public final class Mode {
int max = Collections.max(count.values()); int max = Collections.max(count.values());
ArrayList<Integer> modes = new ArrayList<>(); ArrayList<Integer> modes = new ArrayList<>();
for (int num : count.keySet()) { for (final var entry : count.entrySet()) {
if (count.get(num) == max) { if (entry.getValue() == max) {
modes.add(num); modes.add(entry.getKey());
} }
} }
return modes.stream().mapToInt(n -> n).toArray(); return modes.stream().mapToInt(n -> n).toArray();