33 lines
589 B
Java
33 lines
589 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> liste;
|
||
|
private int indice;
|
||
|
|
||
|
public Iterateur(CouleurList liste) {
|
||
|
this.liste = liste;
|
||
|
this.indice = 0;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean hasNext() {
|
||
|
return this.indice < 10 && this.liste.valeurs[indice] != null;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public T next() {
|
||
|
if (!hasNext()) {
|
||
|
throw new java.util.NoSuchElementException();
|
||
|
}
|
||
|
return this.liste.valeurs[this.indice++];
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|