From a710fe11c47bdfb80342f851c189d167035b7b1c Mon Sep 17 00:00:00 2001
From: Piotr Idzik <65706193+vil02@users.noreply.github.com>
Date: Mon, 24 Jun 2024 10:49:50 +0200
Subject: [PATCH] style: include `SPP_USE_ISEMPTY` (#5238)
---
spotbugs-exclude.xml | 3 ---
.../com/thealgorithms/devutils/nodes/LargeTreeNode.java | 2 +-
src/main/java/com/thealgorithms/searches/QuickSelect.java | 2 +-
.../java/com/thealgorithms/sorts/MergeSortRecursive.java | 6 +++---
4 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml
index 0a535438..9a9712e0 100644
--- a/spotbugs-exclude.xml
+++ b/spotbugs-exclude.xml
@@ -132,9 +132,6 @@
-
-
-
diff --git a/src/main/java/com/thealgorithms/devutils/nodes/LargeTreeNode.java b/src/main/java/com/thealgorithms/devutils/nodes/LargeTreeNode.java
index 1575e364..95d53ecb 100644
--- a/src/main/java/com/thealgorithms/devutils/nodes/LargeTreeNode.java
+++ b/src/main/java/com/thealgorithms/devutils/nodes/LargeTreeNode.java
@@ -64,7 +64,7 @@ public class LargeTreeNode extends TreeNode {
*/
@Override
public boolean isLeafNode() {
- return (childNodes == null || childNodes.size() == 0);
+ return (childNodes == null || childNodes.isEmpty());
}
public Collection> getChildNodes() {
diff --git a/src/main/java/com/thealgorithms/searches/QuickSelect.java b/src/main/java/com/thealgorithms/searches/QuickSelect.java
index c89abb00..d5f69529 100644
--- a/src/main/java/com/thealgorithms/searches/QuickSelect.java
+++ b/src/main/java/com/thealgorithms/searches/QuickSelect.java
@@ -31,7 +31,7 @@ public final class QuickSelect {
public static > T select(List list, int n) {
Objects.requireNonNull(list, "The list of elements must not be null.");
- if (list.size() == 0) {
+ if (list.isEmpty()) {
String msg = "The list of elements must not be empty.";
throw new IllegalArgumentException(msg);
}
diff --git a/src/main/java/com/thealgorithms/sorts/MergeSortRecursive.java b/src/main/java/com/thealgorithms/sorts/MergeSortRecursive.java
index f67ba631..910157b8 100644
--- a/src/main/java/com/thealgorithms/sorts/MergeSortRecursive.java
+++ b/src/main/java/com/thealgorithms/sorts/MergeSortRecursive.java
@@ -34,13 +34,13 @@ public class MergeSortRecursive {
}
private static List sort(List unsortedA, List unsortedB) {
- if (unsortedA.size() <= 0 && unsortedB.size() <= 0) {
+ if (unsortedA.isEmpty() && unsortedB.isEmpty()) {
return new ArrayList<>();
}
- if (unsortedA.size() <= 0) {
+ if (unsortedA.isEmpty()) {
return unsortedB;
}
- if (unsortedB.size() <= 0) {
+ if (unsortedB.isEmpty()) {
return unsortedA;
}
if (unsortedA.get(0) <= unsortedB.get(0)) {