We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d18610 commit 80e440aCopy full SHA for 80e440a
yoonexample/src/main/java/queue/LinkedListQueue.java
@@ -1,5 +1,7 @@
1
package queue;
2
3
+import exception.EmptyQueueException;
4
+
5
public class LinkedListQueue<E> implements Queue<E> {
6
7
private int size;
@@ -30,12 +32,23 @@ public void enqueue(E data) {
30
32
31
33
@Override
34
public E dequeue() {
- return null;
35
+ if (isEmpty()) {
36
+ throw new EmptyQueueException();
37
+ }
38
+ E retData = this.front.data;
39
+ this.front = this.front.next;
40
+ this.size--;
41
42
+ return retData;
43
}
44
45
46
public E peek() {
47
48
49
50
51
+ return this.front.data;
52
53
54
private static class Node<T> {
0 commit comments