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:
Example instance: [switch1=true;switch2=true;switch3=false;switch4=false;switch5=true;]BooleanMapGenotype<Switch> genotype = new BooleanMapGenotype<Switch>(Arrays.asList(switch1, switch2, switch3, switch4, switch5)); genotype.init(new Random());
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, trimToSize
finalize, getClass, notify, notifyAll, wait, wait, wait
add, 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, toArray
protected 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 BooleanGenotype
random
- the random number generatorn
- the number of elements in the resulting genotypeBooleanGenotype.init(java.util.Random, int)
public java.lang.Boolean getValue(K key)
MapGenotype
getValue
in interface MapGenotype<K,java.lang.Boolean>
key
- the keyMapGenotype.setValue(K, V)
public void setValue(K key, java.lang.Boolean value)
MapGenotype
setValue
in interface MapGenotype<K,java.lang.Boolean>
key
- the keyvalue
- the valueMapGenotype.getValue(K)
public boolean containsKey(K key)
MapGenotype
true
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()
Genotype
Genotype
.newInstance
in interface Genotype
newInstance
in class BooleanGenotype
G
- 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)
MapGenotype
getIndexOf
in interface MapGenotype<K,java.lang.Boolean>
key
- the keypublic java.util.Collection<K> getKeys()
MapGenotype
getKeys
in interface MapGenotype<K,java.lang.Boolean>