ListPopulation implements Population { public Iterator<Chromosome> iterator() { return getChromosomes().iterator(); } ListPopulation(final int populationLimit);  ListPopulation(final List<Chromosome> chromosomes, final int populationLimit); @Deprecated void setChromosomes(final List<Chromosome> chromosomes); void addChromosomes(final Collection<Chromosome> chromosomeColl); List<Chromosome> getChromosomes(); void addChromosome(final Chromosome chromosome); Chromosome getFittestChromosome(); int getPopulationLimit(); void setPopulationLimit(final int populationLimit); int getPopulationSize(); @Override String toString(); Iterator<Chromosome> iterator();  }
@Test(expected = UnsupportedOperationException.class) public void testIterator() { final ArrayList<Chromosome> chromosomes = new ArrayList<Chromosome>(); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3))); final ListPopulation population = new ListPopulation(10) { public Population nextGeneration() { return null; } }; population.addChromosomes(chromosomes); final Iterator<Chromosome> iter = population.iterator(); while (iter.hasNext()) { iter.next(); iter.remove(); } }