org.jgap.impl
Class ChromosomePool

java.lang.Object
  extended by org.jgap.impl.ChromosomePool

public class ChromosomePool
extends java.lang.Object

Provides a pooling mechanism for Chromosome instances so that discarded Chromosome instances can be recycled, thus saving memory and the overhead of constructing new ones from scratch each time.


Constructor Summary
ChromosomePool()
          Constructor.
 
Method Summary
 Chromosome acquireChromosome()
          Attempts to acquire an Chromosome instance from the chromosome pool.
 void releaseChromosome(Chromosome a_chromosome)
          Releases a Chromosome to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChromosomePool

public ChromosomePool()
Constructor.

Method Detail

acquireChromosome

public Chromosome acquireChromosome()
Attempts to acquire an Chromosome instance from the chromosome pool. It should be noted that nothing is guaranteed about the value of the Chromosome's genes and they should be treated as undefined.

Returns:
A Chromosome instance from the pool or null if no Chromosome instances are available in the pool.

releaseChromosome

public void releaseChromosome(Chromosome a_chromosome)
Releases a Chromosome to the pool. It's not required that the Chromosome originated from the pool--any Chromosome can be released to it. This method will invoke the cleanup() method on each of the Chromosome's genes prior to adding it back to the pool.

Parameters:
a_chromosome - The Chromosome instance to be released into the pool.