From ba86b4780ee051be168fd59c81b8cf4c2f33cc4d Mon Sep 17 00:00:00 2001 From: hertero Date: Thu, 1 Sep 2022 11:37:28 +0200 Subject: [PATCH] remove-Methode implementiert --- .../src/solution/SimpleArrayMap.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/SimpleArrayMap/src/solution/SimpleArrayMap.java b/SimpleArrayMap/src/solution/SimpleArrayMap.java index 208d1ec..e8cef81 100644 --- a/SimpleArrayMap/src/solution/SimpleArrayMap.java +++ b/SimpleArrayMap/src/solution/SimpleArrayMap.java @@ -64,7 +64,23 @@ public class SimpleArrayMap implements ISimpleMap { @Override public V remove(K k) { - // TODO Auto-generated method stub + + V tempValue; + + if (k == null) { + return null; + } + + for (int i = 0; i < values.length; i++) { + if (k.equals(keys[i])) { + tempValue = values[i]; + keys[i] = null; + values[i] = null; + size--; + return tempValue; + } + } + return null; }