/** * Beschreiben Sie hier die Klasse List_T_. * * @author (Ihr Name) * @version (eine Versionsnummer oder ein Datum) */ public class Queue { private Node first; public Queue() { first = null; } public boolean isEmpty() { if (first == null) return true; return false; } public int size() { Node current = first; int count = 0; while (current != null) { count++; current = current.next; } return count; } public T front(int n) { if (this.first == null) return null; return this.first.wert; } public void enqueue(T val) { Node neu = new Node(); neu.wert = val; if (first == null) { first = neu; } else { Node current = first; // while (current.next != null) { current = current.next; } current.next = neu; } } public T dequeue() { T tmp = first.next.wert; // (Zwischenvariable um gelöschten Wert zu speichern) first.next = first.next.next; // Pfeil auf nächsten verschieben damit er nichr auf gelöschtem Zeigt return tmp; //gelöschten Wert ausgeben } public String toString(){ // glaub um halt alles schön auszugeben String result = ""; Node current = first; while (current != null){ result += current.wert + ", "; current = current.next; } return result; } }