1 10 package org.jgap.impl; 11 12 import org.jgap.*; 13 14 23 public class ChromosomePool 24 implements IChromosomePool { 25 26 private static final String CVS_REVISION = "$Revision: 1.11 $"; 27 28 31 private Pool m_chromosomePool; 32 33 39 public ChromosomePool() { 40 m_chromosomePool = new Pool(); 41 } 42 43 54 public synchronized IChromosome acquireChromosome() { 55 return (IChromosome) m_chromosomePool.acquirePooledObject(); 56 } 57 58 69 public synchronized void releaseChromosome(final IChromosome a_chromosome) { 70 if (a_chromosome == null) { 71 throw new IllegalArgumentException ( 72 "Chromosome instance must not be null!"); 73 } 74 Gene[] genes = a_chromosome.getGenes(); 78 int size = a_chromosome.size(); 79 for (int i = 0; i < size; i++) { 80 genes[i].cleanup(); 81 } 82 m_chromosomePool.releaseObject(a_chromosome); 85 } 86 } 87 | Popular Tags |