Package io.jenetics
Class AbstractChromosome<G extends Gene<?,G>>
- java.lang.Object
-
- io.jenetics.AbstractChromosome<G>
-
- Type Parameters:
G
- the gene type.
- All Implemented Interfaces:
Chromosome<G>
,BaseSeq<G>
,Factory<Chromosome<G>>
,Verifiable
,Serializable
,Iterable<G>
,RandomAccess
- Direct Known Subclasses:
AnyChromosome
,CharacterChromosome
,DoubleChromosome
,IntegerChromosome
,LongChromosome
,PermutationChromosome
public abstract class AbstractChromosome<G extends Gene<?,G>> extends Object implements Chromosome<G>, RandomAccess, Serializable
The abstract base implementation of the Chromosome interface. The implementors of this class must assure that the protected member_genes
is notnull
and the length of thegenes
> 0.- Since:
- 1.0
- Version:
- 5.2
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractChromosome(ISeq<? extends G> genes)
Create a newAbstractChromosome
from the givengenes
array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
G
get(int index)
Return the value at the givenindex
.int
hashCode()
boolean
isValid()
Check if this object is valid.int
length()
Return the length of this sequence.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.jenetics.util.BaseSeq
isEmpty, iterator, listIterator, nonEmpty, spliterator, stream
-
Methods inherited from interface io.jenetics.Chromosome
as, gene, newInstance
-
Methods inherited from interface io.jenetics.util.Factory
instances, newInstance
-
-
-
-
Constructor Detail
-
AbstractChromosome
protected AbstractChromosome(ISeq<? extends G> genes)
Create a newAbstractChromosome
from the givengenes
array.- Parameters:
genes
- the genes that form the chromosome.- Throws:
NullPointerException
- if the given gene array isnull
.IllegalArgumentException
- if the length of the gene sequence is empty.
-
-
Method Detail
-
get
public G get(int index)
Description copied from interface:BaseSeq
Return the value at the givenindex
.
-
length
public int length()
Description copied from interface:BaseSeq
Return the length of this sequence. Once the sequence is created, the length can't be changed.
-
isValid
public boolean isValid()
Description copied from interface:Verifiable
Check if this object is valid.- Specified by:
isValid
in interfaceChromosome<G extends Gene<?,G>>
- Specified by:
isValid
in interfaceVerifiable
- Returns:
- true if this object is valid, false otherwise.
-
-