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

Commit003eec0

Browse files
author
jsquared21
committed
Edit method MyHashMap.remove(key) for efficiency
1 parenta2e5a72 commit003eec0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
3 Bytes
Binary file not shown.

‎Exercise_27/Exercise_27_02/MyHashMap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ public V put(K key, V value) {
160160
publicvoidremove(Kkey) {
161161
intindex =hash(key.hashCode());
162162
intj =0;
163-
163+
164164
while (table.get(index) !=null) {
165-
if (table.get(index).getKey() ==key) {
165+
if (table.get(index).getKey().equals(key)) {
166166
table.remove(index);
167167
size--;// Decrease size
168168
break;// Remove just one entry that matches key

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp