We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
SUI_CONTAINS_BEFORE_ADD
1 parent a2af09c commit 45c2308Copy full SHA for 45c2308
spotbugs-exclude.xml
@@ -222,9 +222,6 @@
222
<Match>
223
<Bug pattern="IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID" />
224
</Match>
225
- <Match>
226
- <Bug pattern="SUI_CONTAINS_BEFORE_ADD" />
227
- </Match>
228
229
<Bug pattern="DRE_DECLARED_RUNTIME_EXCEPTION" />
230
src/main/java/com/thealgorithms/datastructures/graphs/ConnectedComponent.java
@@ -81,8 +81,7 @@ public int countGraphs() {
81
Set<Node> markedNodes = new HashSet<Node>();
82
83
for (Node n : nodeList) {
84
- if (!markedNodes.contains(n)) {
85
- markedNodes.add(n);
+ if (markedNodes.add(n)) {
86
markedNodes.addAll(depthFirstSearch(n, new ArrayList<Node>()));
87
count++;
88
}
0 commit comments