K - the type of key for the mappingV - the type of Genotypepublic 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.
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 and Description |
|---|
CompositeGenotype()
Constructs a
CompositeGenotype. |
CompositeGenotype(java.util.Map<K,V> map)
Constructs a
CompositeGenotype with values from a given map. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all
key, value pairs. |
<G> G |
get(java.lang.Object key)
|
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> |
newInstance()
Constructs a new (empty) instance of this
Genotype. |
void |
put(K key,
V value)
Adds a
key, value pair. |
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. |
public CompositeGenotype()
CompositeGenotype.public CompositeGenotype(java.util.Map<K,V> map)
CompositeGenotype with values from a given map.map - initial valuespublic int size()
GenotypeGenotype.public <G> G get(java.lang.Object key)
G - the type of genotypekey - the keypublic void put(K key, V value)
key, value pair.key - the keyvalue - the value (Genotype)public void clear()
key, value pairs.public java.util.Set<K> keySet()
keys.keyspublic java.util.Collection<V> values()
values which are the contained Genotype
objects.valuespublic java.util.Iterator<java.util.Map.Entry<K,V>> iterator()
Iterator over the Map.Entry pairs.public <G extends Genotype> G newInstance()
GenotypeGenotype.newInstance in interface GenotypeG - the type of genotype for an implicit castpublic java.lang.String toString()
toString in class java.lang.Object