K
- the type of key for the mappingV
- the type of 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 Genotype
s. The method
size()
returns the sum of the sizes of the
contained Genotype
s.
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.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> |
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. |
public CompositeGenotype()
CompositeGenotype
.public CompositeGenotype(java.util.Map<K,V> map)
CompositeGenotype
with values from a given map.map
- initial valuespublic int size()
Genotype
Genotype
.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
.keys
public java.util.Collection<V> values()
values
which are the contained Genotype
objects.values
public java.util.Iterator<java.util.Map.Entry<K,V>> iterator()
Iterator
over the Map.Entry
pairs.public java.util.List<Genotype> getModifiedGenotype()
public void setModifiedGenotypes(java.util.List<Genotype> modifiedGenotypes)
public <G extends Genotype> G newInstance()
Genotype
Genotype
.newInstance
in interface Genotype
G
- the type of genotype for an implicit castpublic java.lang.String toString()
toString
in class java.lang.Object