org.jgap.impl
Class ChromosomePool
- java.lang.Object
-
- org.jgap.impl.ChromosomePool
-
- All Implemented Interfaces:
- IChromosomePool
public class ChromosomePool extends java.lang.Object implements IChromosomePool
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.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor and Description ChromosomePool()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description IChromosomeacquireChromosome()Attempts to acquire an Chromosome instance from the chromosome pool.voidreleaseChromosome(IChromosome a_chromosome)Releases a Chromosome to the pool.
-
-
-
Method Detail
-
acquireChromosome
public IChromosome 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.- Specified by:
acquireChromosomein interfaceIChromosomePool- Returns:
- a Chromosome instance from the pool or null if no Chromosome instances are available in the pool
- Since:
- 1.0
-
releaseChromosome
public void releaseChromosome(IChromosome 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.- Specified by:
releaseChromosomein interfaceIChromosomePool- Parameters:
a_chromosome- the Chromosome instance to be released into the pool- Since:
- 1.0
-
-
DMelt 3.0 © DataMelt by jWork.ORG