Skip to content

Commit c44e749

Browse files
committed
fixes loiane#23
1 parent a5fc23e commit c44e749

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

chapter07/07-HashCollisionLinearProbing.js

+9
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ function HashLinearProbing(){
5353
return table[index].value;
5454
}
5555
}
56+
} else { //search for possible deleted value
57+
var index = ++position;
58+
while (table[index] == undefined || index == table.length ||
59+
(table[index] !== undefined && table[index] && table[index].key !== key)){
60+
index++;
61+
}
62+
if (table[index] && table[index].key === key) {
63+
return table[index].value;
64+
}
5665
}
5766
return undefined;
5867
};

chapter07/08-UsingHashCollisionLinearProbing.js

+8
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ console.log('**** Remove **** ');
2626

2727
hashLinearProbing.remove('Gandalf');
2828
console.log(hashLinearProbing.get('Gandalf'));
29+
hashLinearProbing.print();
30+
31+
console.log('**** Remove Test 2 **** ');
32+
console.log('Removing Jonathan', hashLinearProbing.remove('Jonathan'));
33+
console.log('**** Print **** ');
34+
hashLinearProbing.print();
35+
console.log('Get Jamie', hashLinearProbing.get('Jamie'));
36+
console.log('**** Print **** ');
2937
hashLinearProbing.print();

0 commit comments

Comments
 (0)