Browse Source

put-Methode implementiert

vollständige_und_weitere_testate
hertero 3 years ago
committed by chris
parent
commit
098d8ff311
  1. 25
      SimpleArrayMap/src/solution/SimpleArrayMap.java

25
SimpleArrayMap/src/solution/SimpleArrayMap.java

@ -19,7 +19,30 @@ public class SimpleArrayMap<K, V> implements ISimpleMap<K, V>{
@Override
public V put(K k, V v) {
// TODO Auto-generated method stub
V tempValue;
if (k == null || v == null) {
return null;
}
for (int i = 0; i < values.length; i++) {
if (k.equals(keys[i])) {
tempValue = values[i];
values[i] = v;
return tempValue;
}
}
for (int i = 0; i < values.length; i++) {
if (keys[i] == null) {
keys[i] = k;
values[i] = v;
size++;
break;
}
}
return null;
}

Loading…
Cancel
Save