public class CharacterChromosome extends AbstractChromosome<G> implements CharSequence, Serializable
CharacterGene
,
Serialized Form_genes, _valid
Modifier | Constructor and Description |
---|---|
protected |
CharacterChromosome(ISeq<CharacterGene> genes,
IntRange lengthRange)
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() |
IntRange |
lengthRange()
Return the allowed length range of the chromosome.
|
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(CharSeq validCharacters,
int length)
Create a new chromosome with the
validCharacters char set as
valid characters. |
static CharacterChromosome |
of(CharSeq validCharacters,
IntRange lengthRange)
Create a new chromosome with the
validCharacters char set as
valid characters. |
static CharacterChromosome |
of(int length)
Create a new chromosome with the
CharacterGene.DEFAULT_CHARACTERS
char set as valid characters. |
static CharacterChromosome |
of(IntRange lengthRange)
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
as, getGene, stream
forEach, spliterator
protected CharacterChromosome(ISeq<CharacterGene> genes, IntRange lengthRange)
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.lengthRange
- the allowed length range of the chromosome.NullPointerException
- if the given gene array is null
.IllegalArgumentException
- if the length of the gene array 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()
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(CharSeq validCharacters, IntRange lengthRange)
validCharacters
char set as
valid characters.validCharacters
- the valid characters for this chromosome.lengthRange
- the allowed length range of the chromosome.CharacterChromosome
with the given parameterNullPointerException
- if the validCharacters
is
null
.IllegalArgumentException
- if the length of the gene sequence is
empty, doesn't match with the allowed length range, the minimum
or maximum of the range is smaller or equal zero or the given
range size is zero.public static CharacterChromosome of(IntRange lengthRange)
CharacterGene.DEFAULT_CHARACTERS
char set as valid characters.lengthRange
- the allowed length range of the chromosome.CharacterChromosome
with the given parameterIllegalArgumentException
- if the length
is smaller than
one.public static CharacterChromosome of(CharSeq validCharacters, int length)
validCharacters
char set as
valid characters.validCharacters
- the valid characters for this chromosome.length
- the length
of the new chromosome.CharacterChromosome
with the given parameterNullPointerException
- if the validCharacters
is
null
.IllegalArgumentException
- if the length of the gene sequence is
empty, doesn't match with the allowed length range, the minimum
or maximum of the range is smaller or equal zero or the given
range size is zero.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.public IntRange lengthRange()
© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)