forked from IF-LK-2020/queue-stack
enqueue() & dequeue hinzugefügt
This commit is contained in:
18
Queue.java
18
Queue.java
@@ -9,11 +9,25 @@ public class Queue<ContentType> {
|
||||
}
|
||||
|
||||
public void enqueue( ContentType pContentObject ) {
|
||||
// TODO: Implementiere enqueue
|
||||
QueueNode n = new QueueNode(pContentObject);
|
||||
if(head==null){
|
||||
head = n;
|
||||
tail = n;
|
||||
} else {
|
||||
tail.setNext(n);
|
||||
tail = n;
|
||||
}
|
||||
}
|
||||
|
||||
public void dequeue() {
|
||||
// TODO: Implementiere dequeue
|
||||
if(head != tail){
|
||||
head = head.getNext();
|
||||
} else {
|
||||
if(head != null){
|
||||
head = null;
|
||||
tail = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user