Skip to content

Commit dc8e00e

Browse files
committed
Refactoring
1 parent 9d2c6bd commit dc8e00e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

hashmap.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@ struct hashmap {
55
inline int h (int x) { return (x^179)*7; }
66

77
void add (int x, int y) {
8-
int t = h(x);
9-
int k = t % size;
10-
while (a[k] != -1 && a[k] != t)
8+
int k = h(x) % size;
9+
while (a[k] != -1 && a[k] != x)
1110
k = (k+1) % size;
1211
a[k] = t, b[k] = y;
1312
}
1413

15-
int get (int x, int y) {
16-
int t = h(x);
17-
for (int k = t % size; a[k] != -1; k = (k+1) % size) {
18-
if (a[k] == t)
14+
int get (int x) {
15+
for (int k = h(x) % size; a[k] != -1; k = (k+1) % size) {
16+
if (a[k] == x)
1917
return b[k];
2018
return -1;
2119
}

0 commit comments

Comments
 (0)