Reset size to 0 when clearing table

This commit is contained in:
Manuel Thalmann 2022-11-16 22:14:17 +01:00
parent 13991b6bd2
commit 1d0e670597

View file

@ -31,6 +31,7 @@ public class MyHashtable<K, V> implements Map<K, V> {
// Removes all mappings from this map (optional operation). // Removes all mappings from this map (optional operation).
public void clear() { public void clear() {
size = 0;
keys = (K[]) new Object[capacity]; keys = (K[]) new Object[capacity];
values = (V[]) new Object[capacity]; values = (V[]) new Object[capacity];
} }