01 package fr.isae.lists;
02
03 /**
04 * <code>IterateurListe</code> est un iterateur pour une liste.
05 *
06 * @author <a href="mailto:garion@isae.fr">Christophe Garion</a>
07 * @version 1.0
08 */
09 public class IterateurListe implements Iterateur {
10
11 private Liste liste;
12 private int index;
13
14 /**
15 * Creer un iterateur sur une liste.
16 *
17 * @param liste la liste a parcourir
18 */
19 public IterateurListe(Liste liste) {
20 this.liste = liste;
21 this.index = 0;
22 }
23
24 @Override public void avancer() {
25 this.index++;
26 }
27
28 @Override public boolean estTermine() {
29 return !(this.index < this.liste.getNbElements());
30 }
31
32 @Override public double elementCourant() {
33 return this.liste.getElement(this.index);
34 }
35 }
|