|
@@ -38,14 +38,14 @@ public class ChainQueue<E> implements Queue<E> { |
|
|
@Override |
|
|
@Override |
|
|
public boolean add(E input) { // Übergeben der "Data" |
|
|
public boolean add(E input) { // Übergeben der "Data" |
|
|
if (first == null) { // is the first empty? |
|
|
if (first == null) { // is the first empty? |
|
|
first = new Node(input); // yes? -> |
|
|
|
|
|
|
|
|
first = new Node(input); // yes? -> insert the node here |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
return addNode(input, first); // Andernfalls die Schlage durchlaufen und dort einfügen |
|
|
|
|
|
|
|
|
return addNode(input, first); // no? -> goto addNode() |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private boolean addNode(E input, Node n) { |
|
|
|
|
|
|
|
|
private boolean addNode(E input, Node n) { // run through the queue and find the first "place" which is empty |
|
|
if (n.getNext() == null) { |
|
|
if (n.getNext() == null) { |
|
|
n.setNext(new Node(input)); |
|
|
n.setNext(new Node(input)); |
|
|
return true; |
|
|
return true; |
|
|