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, Iterable<G>, RandomAccess
Direct Known Subclasses:
AbstractTreeChromosome, AnyChromosome, BigIntegerChromosome, CharacterChromosome, DoubleChromosome, IntegerChromosome, LongChromosome, PermutationChromosome

public abstract class AbstractChromosome<G extends Gene<?,G>> extends Object implements Chromosome<G>
The abstract base implementation of the Chromosome interface. The implementors of this class must assure that the protected member _genes is not null and the length of the genes > 0.
Since:
1.0
Version:
5.2
  • Field Details

    • _genes

      protected final transient ISeq<G extends Gene<?,G>> _genes
      Array of genes which forms the chromosome. This array must be initialized by the derived classes.
    • _valid

      protected transient Boolean _valid
      Indicates whether this chromosome is valid or not. If the variable is null the validation state hasn't been calculated yet.
  • Constructor Details

  • Method Details

    • get

      public G get(int index)
      Description copied from interface: BaseSeq
      Return the value at the given index.
      Specified by:
      get in interface BaseSeq<G extends Gene<?,G>>
      Parameters:
      index - index of the element to return.
      Returns:
      the value at the given index.
    • 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.
      Specified by:
      length in interface BaseSeq<G extends Gene<?,G>>
      Returns:
      the length of this sequence.
    • isValid

      public boolean isValid()
      Description copied from interface: Verifiable
      Check if this object is valid.
      Specified by:
      isValid in interface Chromosome<G extends Gene<?,G>>
      Specified by:
      isValid in interface Verifiable
      Returns:
      true if this object is valid, false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object