mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 17:56:02 +08:00
style: include WMI_WRONG_MAP_ITERATOR
(#5206)
This commit is contained in:
@ -68,9 +68,6 @@
|
||||
<Match>
|
||||
<Bug pattern="IM_BAD_CHECK_FOR_ODD" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="WMI_WRONG_MAP_ITERATOR" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="DM_BOXED_PRIMITIVE_FOR_PARSING" />
|
||||
</Match>
|
||||
|
@ -54,19 +54,6 @@ class AdjacencyList<E extends Comparable<E>> {
|
||||
Set<E> getVertices() {
|
||||
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>> {
|
||||
@ -104,9 +91,9 @@ class TopologicalSort<E extends Comparable<E>> {
|
||||
calculateInDegree();
|
||||
Queue<E> q = new LinkedList<E>();
|
||||
|
||||
for (E vertex : inDegree.keySet()) {
|
||||
if (inDegree.get(vertex) == 0) {
|
||||
q.add(vertex);
|
||||
for (final var entry : inDegree.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
q.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,9 @@ public final class MajorityElement {
|
||||
}
|
||||
}
|
||||
List<Integer> majorityElements = new ArrayList<>();
|
||||
for (int key : numToCount.keySet()) {
|
||||
if (numToCount.get(key) >= n / 2) {
|
||||
majorityElements.add(key);
|
||||
for (final var entry : numToCount.entrySet()) {
|
||||
if (entry.getValue() >= n / 2) {
|
||||
majorityElements.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
return majorityElements;
|
||||
|
@ -38,9 +38,9 @@ public final class Mode {
|
||||
int max = Collections.max(count.values());
|
||||
ArrayList<Integer> modes = new ArrayList<>();
|
||||
|
||||
for (int num : count.keySet()) {
|
||||
if (count.get(num) == max) {
|
||||
modes.add(num);
|
||||
for (final var entry : count.entrySet()) {
|
||||
if (entry.getValue() == max) {
|
||||
modes.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
return modes.stream().mapToInt(n -> n).toArray();
|
||||
|
Reference in New Issue
Block a user