@Test public void testSetValue() { Inputs inputs = new Inputs(); SelectMapGenotype<Integer, Integer> genotype = new SelectMapGenotype<>(inputs.list, inputs.map); genotype.init(new Random()); genotype.setValue(2, 3); assertEquals(3, (long) genotype.getValue(2)); genotype.setValue(2, 4); assertEquals(4, (long) genotype.getValue(2)); }
@Override public void setValue(K key, V value) { int i = getIndexOf(key); while (size() <= i) { add(bounds.getLowerBound(i)); } List<V> valueList = values.get(key); if (!valueList.contains(value)) { throw new IllegalArgumentException( "The list provided for key " + key + " does not contain the value " + value); } int v = valueList.indexOf(value); set(i, v); }
SelectMapGenotype extends IntegerGenotype implements MapGenotype<K, V> { @Override public void setValue(K key, V value) { int i = getIndexOf(key); while (size() <= i) { add(bounds.getLowerBound(i)); } List<V> valueList = values.get(key); if (!valueList.contains(value)) { throw new IllegalArgumentException( "The list provided for key " + key + " does not contain the value " + value); } int v = valueList.indexOf(value); set(i, v); } }
SelectMapGenotype extends IntegerGenotype implements MapGenotype<K, V> { @Override public void setValue(K key, V value) { int i = getIndexOf(key); while (size() <= i) { add(bounds.getLowerBound(i)); } List<V> valueList = values.get(key); if (!valueList.contains(value)) { throw new IllegalArgumentException( "The list provided for key " + key + " does not contain the value " + value); } int v = valueList.indexOf(value); set(i, v); } SelectMapGenotype(List<K> keys, Map<K, List<V>> values);  SelectMapGenotype(List<K> keys, List<V> values); }
SelectMapGenotype extends IntegerGenotype implements MapGenotype<K, V> { @Override public void setValue(K key, V value) { int i = getIndexOf(key); while (size() <= i) { add(bounds.getLowerBound(i)); } List<V> valueList = values.get(key); if (!valueList.contains(value)) { throw new IllegalArgumentException( "The list provided for key " + key + " does not contain the value " + value); } int v = valueList.indexOf(value); set(i, v); } SelectMapGenotype(List<K> keys, Map<K, List<V>> values);  SelectMapGenotype(List<K> keys, List<V> values); void init(Random random); @Override void init(Random random, int n); @Override boolean containsKey(K key); @Override int getIndexOf(K key); @Override V getValue(K key); @Override void setValue(K key, V value); @Override @SuppressWarnings({ "unchecked", "rawtypes" }) G newInstance(); @Override String toString(); @Override Collection<K> getKeys(); }
SelectMapGenotype extends IntegerGenotype implements MapGenotype<K, V> { @Override public void setValue(K key, V value) { int i = getIndexOf(key); while (size() <= i) { add(bounds.getLowerBound(i)); } List<V> valueList = values.get(key); if (!valueList.contains(value)) { throw new IllegalArgumentException( "The list provided for key " + key + " does not contain the value " + value); } int v = valueList.indexOf(value); set(i, v); } SelectMapGenotype(List<K> keys, Map<K, List<V>> values);  SelectMapGenotype(List<K> keys, List<V> values); void init(Random random); @Override void init(Random random, int n); @Override boolean containsKey(K key); @Override int getIndexOf(K key); @Override V getValue(K key); @Override void setValue(K key, V value); @Override @SuppressWarnings({ "unchecked", "rawtypes" }) G newInstance(); @Override String toString(); @Override Collection<K> getKeys();  }