import java.util.Iterator; import java.util.NoSuchElementException; /** MonBrinIterator gère la navigation dans un Brin d'ADN */ public class MonBrinIterator implements Iterator { // maillon courant de la navigation private MonMaillon courant; public MonBrinIterator(MonMaillon m){ this.courant = m; } @Override public boolean hasNext(){ return this.courant != null; } @Override public Base next() { if (this.courant == null) { throw new NoSuchElementException("Plus de base dans ce brin"); } Base valeur = this.courant.getBase(); this.courant = this.courant.getSuiteMaillon(); return valeur; } }