29 lines
462 B
Java
29 lines
462 B
Java
package patronIterator;
|
|
|
|
public class IteradorVector {
|
|
private int[] datosVector;
|
|
private int posicion;
|
|
|
|
public IteradorVector(Vector vector) {
|
|
datosVector = vector.getDatos();
|
|
this.posicion = 0;
|
|
}
|
|
|
|
public boolean hasNext() {
|
|
if(posicion < datosVector.length){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public Object next(){
|
|
int valor = datosVector[posicion];
|
|
posicion++;
|
|
return valor;
|
|
}
|
|
|
|
public void reset() {
|
|
posicion=0;
|
|
}
|
|
}
|