Class CompositeGenotype<K,​V extends Genotype>

  • Type Parameters:
    K - the type of key for the mapping
    V - the type of Genotype
    All Implemented Interfaces:
    java.lang.Iterable<java.util.Map.Entry<K,​V>>, Genotype

    public class CompositeGenotype<K,​V extends Genotype>
    extends java.lang.Object
    implements Genotype, java.lang.Iterable<java.util.Map.Entry<K,​V>>

    The CompositeGenotype is a base class for Genotype classes that consist of multiple Genotypes. The method size() returns the sum of the sizes of the contained Genotypes.

    A specific CompositeGenotype has to add each contained Genotype by calling the method put(Object, Genotype) where Object is an arbitrary identifier.

    Example:

            SpecificGenotype extends CompositeGenotype<Integer, Genotype> {
                    public void setDoubleVector(DoubleGenotype genotype){
                            put(0, genotype);
            }
                    public DoubleGenotype getDoubleVector(){ 
                            return get(0);
            }
     
                    public void setBinaryVector(BooleanGenotype genotype){
                            put(1, genotype);
                    }
                    public BooleanGenotype getDoubleVector(){
                            return get(1); 
                    }
     }
     

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<K,​V> map  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Removes all key, value pairs.
      <G> G get​(java.lang.Object key)
      Returns the Genotype for the given key with an implicit cast to the specific Genotype type.
      java.util.List<Genotype> getModifiedGenotype()  
      java.util.Iterator<java.util.Map.Entry<K,​V>> iterator()
      Returns the Iterator over the Map.Entry pairs.
      java.util.Set<K> keySet()
      Returns all keys.
      <G extends Genotype>
      G
      newInstance()
      Constructs a new (empty) instance of this Genotype.
      void put​(K key, V value)
      Adds a key, value pair.
      void setModifiedGenotypes​(java.util.List<Genotype> modifiedGenotypes)  
      int size()
      The number of atomic elements of the Genotype.
      java.lang.String toString()  
      java.util.Collection<V> values()
      Returns all values which are the contained Genotype objects.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • map

        protected final java.util.Map<K,​V extends Genotype> map
    • Constructor Detail

      • CompositeGenotype

        public CompositeGenotype​(java.util.Map<K,​V> map)
        Constructs a CompositeGenotype with values from a given map.
        Parameters:
        map - initial values
    • Method Detail

      • size

        public int size()
        Description copied from interface: Genotype
        The number of atomic elements of the Genotype.
        Specified by:
        size in interface Genotype
        Returns:
        number of atomic elements of the genotype
      • get

        public <G> G get​(java.lang.Object key)
        Returns the Genotype for the given key with an implicit cast to the specific Genotype type.
        Type Parameters:
        G - the type of genotype
        Parameters:
        key - the key
        Returns:
        the addressed genotype
      • put

        public void put​(K key,
                        V value)
        Adds a key, value pair.
        Parameters:
        key - the key
        value - the value (Genotype)
      • clear

        public void clear()
        Removes all key, value pairs.
      • keySet

        public java.util.Set<K> keySet()
        Returns all keys.
        Returns:
        all keys
      • values

        public java.util.Collection<V> values()
        Returns all values which are the contained Genotype objects.
        Returns:
        all values
      • iterator

        public java.util.Iterator<java.util.Map.Entry<K,​V>> iterator()
        Returns the Iterator over the Map.Entry pairs.
        Specified by:
        iterator in interface java.lang.Iterable<K>
        Returns:
        the iterator over the entry pairs
      • getModifiedGenotype

        public java.util.List<Genotype> getModifiedGenotype()
      • setModifiedGenotypes

        public void setModifiedGenotypes​(java.util.List<Genotype> modifiedGenotypes)
      • newInstance

        public <G extends Genotype> G newInstance()
        Description copied from interface: Genotype
        Constructs a new (empty) instance of this Genotype.
        Specified by:
        newInstance in interface Genotype
        Type Parameters:
        G - the type of genotype for an implicit cast
        Returns:
        new instance of the genotype
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object