We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2870c6d commit a2c6869Copy full SHA for a2c6869
Exercise_27/Exercise_27_03/MyHashMap.class
22 Bytes
Exercise_27/Exercise_27_03/MyHashMap.java
@@ -92,16 +92,16 @@ public V get(K key) {
92
int index = hash1;
93
int j = 0;
94
95
- while (table.get(index) == null) {
+ while (table.get(index) != null) {
96
+ if (table.get(index).getKey().equals(key)) {
97
+ return table.get(index).getValue();
98
+ }
99
+
100
// Secondary hash: (k + j * h'(key)) % N
101
index = hash1 + j++ * hash2(hash1);
102
index %= capacity;
103
}
104
- if (table.get(index).getKey() == key) {
- return table.get(index).getValue();
- }
-
105
return null;
106
107
0 commit comments