package jcgp.population; import java.util.Iterator; import jcgp.CGP.Parameters; public class Population implements Iterable { private Chromosome[] population; public Population() { population = new Chromosome[Parameters.getPopulationSize()]; for (int c = 0; c < population.length; c++) { population[c] = new Chromosome(Parameters.getInputs(), Parameters.getRows(), Parameters.getColumns(), Parameters.getOutputs()); } } @Override public Iterator iterator() { return new Iterator() { private int index = 0; @Override public boolean hasNext() { if (index < population.length) { return true; } else { return false; } } @Override public Chromosome next() { Chromosome next = population[index]; index++; return next; } @Override public void remove() { // not allowed } }; } }