Browse Source

removed unnecessary lines and added header

master
David 4 years ago
parent
commit
57d3c08518
2 changed files with 12 additions and 8 deletions
  1. +6
    -6
      src/ChainQueue.java
  2. +6
    -2
      src/HUE_06_Generics.java

+ 6
- 6
src/ChainQueue.java View File

@@ -1,12 +1,15 @@
/************************************************
* Name: David Wurm
* Datum: 25.11.2019
* Klasse: 3AHIF
* Programm: HUE_06_GenericsQueue
************************************************/
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.Queue; import java.util.Queue;



public class ChainQueue<E> implements Queue<E> { public class ChainQueue<E> implements Queue<E> {

private class Node<E> { private class Node<E> {

private E data; private E data;
private Node<E> next; private Node<E> next;


@@ -30,7 +33,6 @@ public class ChainQueue<E> implements Queue<E> {
this.data = data; this.data = data;


} }

} }


Node<E> first; // first item of the queue Node<E> first; // first item of the queue
@@ -42,7 +44,6 @@ public class ChainQueue<E> implements Queue<E> {
return true; return true;
} }
return addNode(input, first); // no? -> goto addNode() 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 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 true;
} }
return addNode(input, n.getNext()); return addNode(input, n.getNext());

} }


@Override @Override


+ 6
- 2
src/HUE_06_Generics.java View File

@@ -1,5 +1,10 @@
/************************************************
* Name: David Wurm
* Datum: 25.11.2019
* Klasse: 3AHIF
* Programm: HUE_06_GenericsQueue
************************************************/
import java.util.Queue; import java.util.Queue;

public class HUE_06_Generics { public class HUE_06_Generics {
public static void main(String[] args) { public static void main(String[] args) {
Queue<String> strs = new ChainQueue<String>(); Queue<String> strs = new ChainQueue<String>();
@@ -14,6 +19,5 @@ public class HUE_06_Generics {
System.out.println(" - " + strs.poll() + " #" + strs.size()); System.out.println(" - " + strs.poll() + " #" + strs.size());
System.out.println(" - " + strs.poll() + " #" + strs.size()); System.out.println(" - " + strs.poll() + " #" + strs.size());
System.out.println(" - " + strs.poll() + " #" + strs.size()); System.out.println(" - " + strs.poll() + " #" + strs.size());

} }
} }

Loading…
Cancel
Save