G
- the gene type.public abstract class AbstractChromosome<G extends Gene<?,G>> extends Object implements Chromosome<G>, RandomAccess
_genes
is not
null
and the length of the genes
> 0.Modifier and Type | Field and Description |
---|---|
protected ISeq<G> |
_genes
Array of genes which forms the chromosome.
|
protected Boolean |
_valid
Indicates whether this chromosome is valid or not.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractChromosome(ISeq<? extends G> genes)
Create a new
AbstractChromosome from the given genes
array. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
G |
getGene()
Return the first gene of this chromosome.
|
G |
getGene(int index)
Return the gene on the specified index.
|
int |
hashCode() |
protected int |
indexOf(Object gene)
Return the index of the first occurrence of the given
gene . |
boolean |
isValid()
Check if this object is valid.
|
Iterator<G> |
iterator() |
int |
length()
Returns the length of the Chromosome.
|
ISeq<G> |
toSeq()
Return an unmodifiable sequence of the genes of this chromosome.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
newInstance
newInstance
protected transient ISeq<G extends Gene<?,G>> _genes
protected AbstractChromosome(ISeq<? extends G> genes)
AbstractChromosome
from the given genes
array. The genes array is not copied, but sealed, so changes to the given
genes array doesn't effect the genes of this chromosome.genes
- the genes that form the chromosome.NullPointerException
- if the given gene array is null
.IllegalArgumentException
- if the length of the gene array is
smaller than one.public G getGene(int index)
Chromosome
getGene
in interface Chromosome<G extends Gene<?,G>>
index
- The gene index.public G getGene()
Chromosome
getGene
in interface Chromosome<G extends Gene<?,G>>
public ISeq<G> toSeq()
Chromosome
toSeq
in interface Chromosome<G extends Gene<?,G>>
public boolean isValid()
Verifiable
isValid
in interface Verifiable
public int length()
Chromosome
length
in interface Chromosome<G extends Gene<?,G>>
protected int indexOf(Object gene)
gene
.gene
- the Gene
to search for.© 2007-2014 Franz Wilhelmstötter (2014-03-07 19:35)