33 lines
592 B
Java
33 lines
592 B
Java
import java.awt.*;
|
|
import javax.swing.*;
|
|
import java.util.List;
|
|
import java.util.Iterator;
|
|
import java.util.NoSuchElementException;
|
|
|
|
public class Iterateur<T> implements Iterator<T> {
|
|
|
|
private CouleurList<T> actuel;
|
|
|
|
public Iterateur(CouleurList debut) {
|
|
this.actuel = debut;
|
|
}
|
|
|
|
@Override
|
|
public boolean hasNext() {
|
|
return (this.actuel != null && this.actuel.valeur != null);
|
|
}
|
|
|
|
@Override
|
|
public T next() {
|
|
if (!hasNext()) {
|
|
throw new java.util.NoSuchElementException();
|
|
}
|
|
T valeur = this.actuel.valeur;
|
|
this.actuel = this.actuel.suivant;
|
|
return valeur;
|
|
}
|
|
|
|
}
|
|
|
|
|