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

Commit bd73d1f

Browse files
committed
update: change in the Node structure
1 parent d221391 commit bd73d1f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

‎src/_DataStructures_/HashTable/HashEntry.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class HashEntry {
2-
constructor(key, value) {
2+
constructor({key, value}) {
33
this.key = key;
44
this.value = value;
55
this.next = null;

‎src/_DataStructures_/HashTable/index.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Node }= require('../LinkedList');
1+
const HashEntry= require('./HashEntry');
22

33
class HashTable {
44
constructor(slots) {
@@ -37,7 +37,7 @@ class HashTable {
3737
* Util to add a SSL to the index in case of more than once
3838
* value for the same key exixts
3939
*/
40-
const node = new Node(value);
40+
const node = new HashEntry(value);
4141
if (!this.bucket[index]) {
4242
this.bucket[index] = node;
4343
this.size += 1;
@@ -62,8 +62,8 @@ class HashTable {
6262
const res = [];
6363
let head = this.bucket[index];
6464
while (head !== null) {
65-
if (head.data.key === key) {
66-
res.push(head.data.value);
65+
if (head.key === key) {
66+
res.push(head.value);
6767
}
6868
head = head.next;
6969
}
@@ -96,7 +96,7 @@ class HashTable {
9696
}
9797
}
9898

99-
// const ht = new HashTable();
99+
// const ht = new HashTable(5);
100100
// ht.set('hello', 'I am a new value');
101101
// ht.set('hello', 'I am a yet another value');
102102
// ht.set('maroon', 'I maroon');

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /