Class CompositeGenotype<K,​V extends Genotype>

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

    public class CompositeGenotype<K,​V extends Genotype>
    extends Object
    implements Genotype, Iterable<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); 
                    }
     }
     

    • Constructor Detail

      • CompositeGenotype

        public CompositeGenotype​(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​(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 Set<K> keySet()
        Returns all keys.
        Returns:
        all keys
      • values

        public Collection<V> values()
        Returns all values which are the contained Genotype objects.
        Returns:
        all values
      • 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