From 493942e319dfe674f344d13e5df832d183bd11bd Mon Sep 17 00:00:00 2001
From: Piotr Idzik <65706193+vil02@users.noreply.github.com>
Date: Tue, 4 Jun 2024 22:54:38 +0200
Subject: [PATCH] style: include `IT_NO_SUCH_ELEMENT` (#5200)
---
spotbugs-exclude.xml | 3 ---
.../thealgorithms/datastructures/queues/LinkedQueue.java | 7 +++++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml
index 711b34b0..ae10d104 100644
--- a/spotbugs-exclude.xml
+++ b/spotbugs-exclude.xml
@@ -77,9 +77,6 @@
-
-
-
diff --git a/src/main/java/com/thealgorithms/datastructures/queues/LinkedQueue.java b/src/main/java/com/thealgorithms/datastructures/queues/LinkedQueue.java
index 8a788317..171f24e0 100644
--- a/src/main/java/com/thealgorithms/datastructures/queues/LinkedQueue.java
+++ b/src/main/java/com/thealgorithms/datastructures/queues/LinkedQueue.java
@@ -148,8 +148,11 @@ public class LinkedQueue implements Iterable {
@Override
public T next() {
- node = node.next;
- return node.data;
+ if (hasNext()) {
+ node = node.next;
+ return node.data;
+ }
+ throw new NoSuchElementException();
}
};
}