isEmpty und toFirst
public boolean isEmpty() { if (zaehler==0) return true; else return false; } /* * Die Methode toFirst() setzt current auf das erste Element. * Wenn die Liste leer ist, soll nichts verändert werden. */ public void toFirst() // { current = first; }
next
public void next() { if (!isEmpty()){ if (current.getNext() != null){ current = current.getNext(); }else{ current = first; } } }
previous
public void previous() { for (int i = 0; i < count; i++){ current = current.getNext(); } }
addFirst
public void addFirst(ListenElement new ListenElement) { if (first == null) { first = newListenElement; current = newListenElement; } else { newListenElement.next = first; first = newListenElement; } zaehler = zaehler +1; }
suchen
public String suchen (String suche) { current = first; while(current.next != null) { if(current.getInhalt()==suche) return current.getInhalt(); current = current.getNext(); } return suche + " kann nicht gefunden werdern"; }