Skip to content

Commit 2dd4468

Browse files
author
jsquared21
committed
Decrease size when entry is removed MyHashMap.remove
1 parent b9ece73 commit 2dd4468

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
18 Bytes
Binary file not shown.

Exercise_27/Exercise_27_02/MyHashMap.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,10 @@ public void remove(K key) {
170170
index %= capacity;
171171
}
172172

173-
if (table.get(index).getKey() == key)
173+
if (table.get(index).getKey() == key) {
174174
table.remove(index);
175+
size--; // Decrease size
176+
}
175177
}
176178

177179
@Override /** Return the number of entries in this map */

0 commit comments

Comments
 (0)