K - the type of keyspublic class BooleanMapGenotype<K> extends BooleanGenotype implements MapGenotype<K,java.lang.Boolean>
The BooleanMapGenotype is a BooleanGenotype with the
MapGenotype functionality.
Example problem: Select on/off state of five switches switch1,
switch2, switch3, switch4,
switch5
Example usage:
BooleanMapGenotype<Switch> genotype = new BooleanMapGenotype<Switch>(Arrays.asList(switch1, switch2, switch3, switch4,
switch5));
genotype.init(new Random());
Example instance:
[switch1=true;switch2=true;switch3=false;switch4=false;switch5=true;] | Constructor and Description |
|---|
BooleanMapGenotype(java.util.List<K> list)
Constructs a
BooleanMapGenotype. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(K key)
Returns
true if the key is contained. |
int |
getIndexOf(K key)
Returns the index of the key.
|
java.util.Collection<K> |
getKeys()
Return all keys.
|
java.lang.Boolean |
getValue(K key)
Returns the value for the specified key.
|
void |
init(java.util.Random random)
Initialize this genotype with random values based on the number of keys.
|
void |
init(java.util.Random random,
int n)
Not supported.
|
<G extends Genotype> |
newInstance()
Constructs a new (empty) instance of this
Genotype. |
void |
setValue(K key,
java.lang.Boolean value)
Sets the value for the specified key.
|
java.lang.String |
toString() |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizefinalize, getClass, notify, notifyAll, wait, wait, waitadd, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArrayprotected final java.util.List<K> list
public BooleanMapGenotype(java.util.List<K> list)
BooleanMapGenotype.list - the list of keyspublic void init(java.util.Random random)
random - the random number generatorpublic void init(java.util.Random random,
int n)
init(Random) instead.init in class BooleanGenotyperandom - the random number generatorn - the number of elements in the resulting genotypeBooleanGenotype.init(java.util.Random, int)public java.lang.Boolean getValue(K key)
MapGenotypegetValue in interface MapGenotype<K,java.lang.Boolean>key - the keyMapGenotype.setValue(K, V)public void setValue(K key, java.lang.Boolean value)
MapGenotypesetValue in interface MapGenotype<K,java.lang.Boolean>key - the keyvalue - the valueMapGenotype.getValue(K)public boolean containsKey(K key)
MapGenotypetrue if the key is contained.containsKey in interface MapGenotype<K,java.lang.Boolean>key - the keytrue if the key is containedpublic <G extends Genotype> G newInstance()
GenotypeGenotype.newInstance in interface GenotypenewInstance in class BooleanGenotypeG - the type of genotype for an implicit castpublic java.lang.String toString()
toString in class java.util.AbstractCollection<java.lang.Boolean>public int getIndexOf(K key)
MapGenotypegetIndexOf in interface MapGenotype<K,java.lang.Boolean>key - the keypublic java.util.Collection<K> getKeys()
MapGenotypegetKeys in interface MapGenotype<K,java.lang.Boolean>