public class CharacterChromosome extends AbstractChromosome<CharacterGene> implements CharSequence, Serializable
_genes, _valid
Modifier | Constructor and Description |
---|---|
|
CharacterChromosome(CharSeq validCharacters,
int length)
Create a new chromosome with the
validCharacters char set as
valid characters. |
protected |
CharacterChromosome(ISeq<CharacterGene> genes)
Create a new chromosome from the given
genes array. |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index) |
boolean |
equals(Object obj) |
int |
hashCode() |
CharacterChromosome |
newInstance()
Create a new, random chromosome.
|
CharacterChromosome |
newInstance(ISeq<CharacterGene> genes)
A factory method which creates a new
Chromosome of specific type
and the given genes . |
static CharacterChromosome |
of(int length)
Create a new chromosome with the
CharacterGene.DEFAULT_CHARACTERS
char set as valid characters. |
static CharacterChromosome |
of(String alleles)
Create a new chromosome from the given genes (given as string).
|
static CharacterChromosome |
of(String alleles,
CharSeq validChars)
Create a new chromosome from the given genes (given as string).
|
CharacterChromosome |
subSequence(int start,
int end) |
char[] |
toArray()
Returns an char array containing all of the elements in this chromosome
in proper sequence.
|
char[] |
toArray(char[] array)
Returns an char array containing all of the elements in this chromosome
in proper sequence.
|
String |
toString() |
getGene, isValid, iterator, length, toSeq
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
chars, codePoints, length
getGene, stream
forEach, spliterator
protected CharacterChromosome(ISeq<CharacterGene> genes)
genes
array. The genes
array is copied, 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 CharacterChromosome(CharSeq validCharacters, int length)
validCharacters
char set as
valid characters.validCharacters
- the valid characters for this chromosome.length
- the length of the new chromosome.NullPointerException
- if the validCharacters
is
null
.IllegalArgumentException
- if the length
is smaller than
one.public char charAt(int index)
charAt
in interface CharSequence
public CharacterChromosome subSequence(int start, int end)
subSequence
in interface CharSequence
public CharacterChromosome newInstance(ISeq<CharacterGene> genes)
Chromosome
Chromosome
of specific type
and the given genes
.newInstance
in interface Chromosome<CharacterGene>
genes
- the genes of the new chromosome. The given genes array is
not copied.Chromosome
of the same type with the given genes.NullPointerException
- if the given gene array is null
.public CharacterChromosome newInstance()
newInstance
in interface Factory<Chromosome<CharacterGene>>
public int hashCode()
hashCode
in class AbstractChromosome<CharacterGene>
public boolean equals(Object obj)
equals
in class AbstractChromosome<CharacterGene>
public String toString()
toString
in interface CharSequence
toString
in class AbstractChromosome<CharacterGene>
public char[] toArray(char[] array)
array
- the array into which the elements of this chromosomes are to
be stored, if it is big enough; otherwise, a new array is
allocated for this purpose.NullPointerException
- if the given array
is null
public char[] toArray()
public static CharacterChromosome of(int length)
CharacterGene.DEFAULT_CHARACTERS
char set as valid characters.length
- the length
of the new chromosome.CharacterChromosome
with the given parameterIllegalArgumentException
- if the length
is smaller than
one.public static CharacterChromosome of(String alleles, CharSeq validChars)
alleles
- the character genes.validChars
- the valid characters.CharacterChromosome
with the given parameterIllegalArgumentException
- if the genes string is empty.public static CharacterChromosome of(String alleles)
alleles
- the character genes.CharacterChromosome
with the given parameterIllegalArgumentException
- if the genes string is empty.© 2007-2016 Franz Wilhelmstötter (2016-04-24 10:25)