Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2dd4468

Browse files
author
jsquared21
committed
Decrease size when entry is removed MyHashMap.remove
1 parentb9ece73 commit2dd4468

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)

[8]ページ先頭

©2009-2025 Movatter.jp