removing all e in bucket, "use" should decrease

删除槽中所有元素后,hash表占用变量use需要减1。
This commit is contained in:
damianzhenxiaozhi 2019-09-27 18:31:22 +08:00 committed by GitHub
parent 63e2dd2ff1
commit d4eac2fdcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,12 +142,14 @@ public class HashTable<K, V> {
}
Entry pre;
Entry<K, V> headNode = table[index];
do {
pre = e;
e = e.next;
if (key == e.key) {
pre.next = e.next;
size--;
if (headNode.next == null) use--;
return;
}
} while (e.next != null);