fin tp3
This commit is contained in:
32
DEV3.2/TP03/02_Chaine/Iterateur.java
Normal file
32
DEV3.2/TP03/02_Chaine/Iterateur.java
Normal file
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user