|
|
@@ -1,12 +1,15 @@ |
|
|
|
/************************************************ |
|
|
|
* Name: David Wurm |
|
|
|
* Datum: 25.11.2019 |
|
|
|
* Klasse: 3AHIF |
|
|
|
* Programm: HUE_06_GenericsQueue |
|
|
|
************************************************/ |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Queue; |
|
|
|
|
|
|
|
|
|
|
|
public class ChainQueue<E> implements Queue<E> { |
|
|
|
|
|
|
|
private class Node<E> { |
|
|
|
|
|
|
|
private E data; |
|
|
|
private Node<E> next; |
|
|
|
|
|
|
@@ -30,7 +33,6 @@ public class ChainQueue<E> implements Queue<E> { |
|
|
|
this.data = data; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Node<E> first; // first item of the queue |
|
|
@@ -42,7 +44,6 @@ public class ChainQueue<E> implements Queue<E> { |
|
|
|
return true; |
|
|
|
} |
|
|
|
return addNode(input, first); // no? -> goto addNode() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private boolean addNode(E input, Node n) { // run through the queue and find the first "place" which is empty |
|
|
@@ -51,7 +52,6 @@ public class ChainQueue<E> implements Queue<E> { |
|
|
|
return true; |
|
|
|
} |
|
|
|
return addNode(input, n.getNext()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|