Parcourir la source

restructured code, finalizing

master
David il y a 4 ans
Parent
révision
d8c6c0e53b
1 fichiers modifiés avec 25 ajouts et 23 suppressions
  1. +25
    -23
      src/ChainQueue.java

+ 25
- 23
src/ChainQueue.java Voir le fichier

@@ -94,6 +94,31 @@ public class ChainQueue<E> implements Queue<E> {
return false;
}

@Override
public E poll() { // poll next from queue and remove the first
E temp = null;
if (!this.isEmpty()) {
temp = getFirst().getData();
setFirst(getFirst().getNext());
}
return temp;
}

@Override
public E element() {
return null;
}

@Override
public E peek() { // only "see" into the queue and do not remove anything
if (!this.isEmpty()) {
return getFirst().getData();
}
return null;
}

/*** the following is not implemented because it's not needed here ***/

@Override
public Iterator<E> iterator() {
return null;
@@ -148,27 +173,4 @@ public class ChainQueue<E> implements Queue<E> {
public E remove() {
return null;
}

@Override
public E poll() { // poll next from queue and remove the first
E temp = null;
if (!this.isEmpty()) {
temp = getFirst().getData();
setFirst(getFirst().getNext());
}
return temp;
}

@Override
public E element() {
return null;
}

@Override
public E peek() { // only "see" into the queue and do not remove anything
if (!this.isEmpty()) {
return getFirst().getData();
}
return null;
}
}

Chargement…
Annuler
Enregistrer