K
- the type of keyspublic class IntegerMapGenotype<K> extends IntegerGenotype implements MapGenotype<K,java.lang.Integer>
The IntegerMapGenotype
is a IntegerGenotype
with the
MapGenotype
functionality.
Example problem: Select the outcome of throwing five dice die1,
die2, die3, die4, die5
Example usage:
Example instance: [die1=3, die2=5, die3=6, die4=1, die5=3]IntegerGenotype<Die> genotype = new IntegerMapGenotype<Die>(Arrays.asList(die1, die2, die3, die4, die5), 1, 6); genotype.init(new Random());
Modifier and Type | Field and Description |
---|---|
protected java.util.List<K> |
list |
bounds
Constructor and Description |
---|
IntegerMapGenotype(java.util.List<K> list,
Bounds<java.lang.Integer> bounds)
Constructs a
IntegerMapGenotype . |
IntegerMapGenotype(java.util.List<K> list,
int lowerBound,
int upperBound)
Constructs a
IntegerMapGenotype with fixed bounds. |
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.Integer |
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 size of the
list . |
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.Integer value)
Sets the value for the specified key.
|
java.lang.String |
toString() |
getLowerBound, getUpperBound
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 IntegerMapGenotype(java.util.List<K> list, Bounds<java.lang.Integer> bounds)
IntegerMapGenotype
.list
- the list of keysbounds
- the lower and upper boundspublic IntegerMapGenotype(java.util.List<K> list, int lowerBound, int upperBound)
IntegerMapGenotype
with fixed bounds.list
- the list of keyslowerBound
- the lower boundupperBound
- the upper boundpublic void init(java.util.Random random)
list
.random
- the random number generatorpublic void init(java.util.Random random, int n)
init(Random)
instead.init
in class IntegerGenotype
random
- the random number generatorn
- the number of elements in the resulting genotypeIntegerGenotype.init(java.util.Random, int)
public boolean containsKey(K key)
MapGenotype
true
if the key is contained.containsKey
in interface MapGenotype<K,java.lang.Integer>
key
- the keytrue
if the key is containedpublic java.lang.Integer getValue(K key)
MapGenotype
getValue
in interface MapGenotype<K,java.lang.Integer>
key
- the keyMapGenotype.setValue(K, V)
public void setValue(K key, java.lang.Integer value)
MapGenotype
setValue
in interface MapGenotype<K,java.lang.Integer>
key
- the keyvalue
- the valueMapGenotype.getValue(K)
public <G extends Genotype> G newInstance()
Genotype
Genotype
.newInstance
in interface Genotype
newInstance
in class IntegerGenotype
G
- the type of genotype for an implicit castpublic java.lang.String toString()
toString
in class java.util.AbstractCollection<java.lang.Integer>
public int getIndexOf(K key)
MapGenotype
getIndexOf
in interface MapGenotype<K,java.lang.Integer>
key
- the keypublic java.util.Collection<K> getKeys()
MapGenotype
getKeys
in interface MapGenotype<K,java.lang.Integer>