@@ -2,23 +2,22 @@ const { HashTableSeparateChaining } = PacktDataStructuresAlgorithms;
2
2
3
3
const hashTable = new HashTableSeparateChaining ( ) ;
4
4
5
- hashTable . put ( 'Gandalf' , 'gandalf@email.com' ) ;
6
- hashTable . put ( 'John' , 'johnsnow@email.com' ) ;
7
- hashTable . put ( 'Tyrion' , 'tyrion@email.com' ) ;
8
- hashTable . put ( 'Aaron' , 'aaron@email.com' ) ;
9
- hashTable . put ( 'Donnie' , 'donnie@email.com' ) ;
10
- hashTable . put ( 'Ana' , 'ana@email.com' ) ;
5
+ hashTable . put ( 'Ygritte' , 'ygritte@email.com' ) ;
11
6
hashTable . put ( 'Jonathan' , 'jonathan@email.com' ) ;
12
7
hashTable . put ( 'Jamie' , 'jamie@email.com' ) ;
13
- hashTable . put ( 'Sue ' , 'sue @email.com' ) ;
14
- hashTable . put ( 'Mindy ' , 'mindy @email.com' ) ;
15
- hashTable . put ( 'Paul ' , 'paul @email.com' ) ;
8
+ hashTable . put ( 'Jack ' , 'jack @email.com' ) ;
9
+ hashTable . put ( 'Jasmine ' , 'jasmine @email.com' ) ;
10
+ hashTable . put ( 'Jake ' , 'jake @email.com' ) ;
16
11
hashTable . put ( 'Nathan' , 'nathan@email.com' ) ;
12
+ hashTable . put ( 'Athelstan' , 'athelstan@email.com' ) ;
13
+ hashTable . put ( 'Sue' , 'sue@email.com' ) ;
14
+ hashTable . put ( 'Aethelwulf' , 'aethelwulf@email.com' ) ;
15
+ hashTable . put ( 'Sargeras' , 'sargeras@email.com' ) ;
17
16
18
17
console . log ( '**** Printing Hash **** ' ) ;
19
18
20
19
console . log ( hashTable . toString ( ) ) ;
21
- // {5 => [#Jonathan: jonathan @email.com],[#Jamie: jamie@email.com],[#Sue: sue @email.com] },{10 => [#Nathan: nathan @email .com]},{13 => [#Donnie: donnie @email .com],[#Ana: ana @email.com]},{16 => [#Tyrion: tyrion @email .com],[#Aaron: aaron @email.com]},{19 => [#Gandalf: gandalf @email .com]},{29 => [#John: johnsnow @email .com]},{32 => [#Mindy: mindy @email .com],[#Paul: paul @email.com]}
20
+ // {4 => [#Ygritte: ygritte @email.com] },{5 => [#Jonathan: jonathan @email .com],[#Jamie: jamie @email.com],[#Sue: sue @email.com],[#Aethelwulf: aethelwulf @email.com]},{7 => [#Jack: jack @email .com],[#Athelstan: athelstan @email.com]},{8 => [#Jasmine: jasmine @email .com]},{9 => [#Jake: jake @email .com]},{10 => [#Nathan: nathan @email .com],[#Sargeras: sargeras @email.com]}
22
21
23
22
console . log ( '**** Get **** ' ) ;
24
23
@@ -29,19 +28,19 @@ console.log(hashTable.get('Loiane')); // undefined
29
28
30
29
console . log ( '**** Remove **** ' ) ;
31
30
32
- console . log ( hashTable . remove ( 'Gandalf ' ) ) ; // true
33
- console . log ( hashTable . get ( 'Gandalf ' ) ) ; // undefined
31
+ console . log ( hashTable . remove ( 'Ygritte ' ) ) ; // true
32
+ console . log ( hashTable . get ( 'Ygritte ' ) ) ; // undefined
34
33
console . log ( hashTable . toString ( ) ) ;
35
- // {5 => [#Jonathan: jonathan@email.com],[#Jamie: jamie@email.com],[#Sue: sue@email.com] },{10 => [#Nathan: nathan @email .com]},{13 => [#Donnie: donnie @email .com],[#Ana: ana @email.com]},{16 => [#Tyrion: tyrion @email .com],[#Aaron: aaron@email.com] },{29 => [#John: johnsnow @email .com]},{32 => [#Mindy: mindy @email .com],[#Paul: paul @email.com]}
34
+ // {5 => [#Jonathan: jonathan@email.com],[#Jamie: jamie@email.com],[#Sue: sue@email.com],[#Aethelwulf: aethelwulf @email.com] },{7 => [#Jack: jack @email .com],[#Athelstan: athelstan @email.com]},{8 => [#Jasmine: jasmine @email .com]},{9 => [#Jake: jake @email .com]},{10 => [#Nathan: nathan @email .com],[#Sargeras: sargeras @email.com]}
36
35
37
36
console . log ( hashTable . remove ( 'Sue' ) ) ; // true
38
37
console . log ( hashTable . toString ( ) ) ;
39
- // {5 => [#Jonathan: jonathan@email.com],[#Jamie: jamie@email.com] },{10 => [#Nathan: nathan @email .com]},{13 => [#Donnie: donnie @email .com],[#Ana: ana @email.com]},{16 => [#Tyrion: tyrion @email .com],[#Aaron: aaron@email.com] },{29 => [#John: johnsnow @email .com]},{32 => [#Mindy: mindy @email .com],[#Paul: paul @email.com]}
38
+ // {5 => [#Jonathan: jonathan@email.com],[#Jamie: jamie@email.com],[#Aethelwulf: aethelwulf @email.com] },{7 => [#Jack: jack @email .com],[#Athelstan: athelstan @email.com]},{8 => [#Jasmine: jasmine @email .com]},{9 => [#Jake: jake @email .com]},{10 => [#Nathan: nathan @email .com],[#Sargeras: sargeras @email.com]}
40
39
41
40
console . log ( hashTable . remove ( 'Jamie' ) ) ; // true
42
41
console . log ( hashTable . toString ( ) ) ;
43
- // {5 => [#Jonathan: jonathan@email.com] },{10 => [#Nathan: nathan @email .com]},{13 => [#Donnie: donnie @email .com],[#Ana: ana @email.com]},{16 => [#Tyrion: tyrion @email .com],[#Aaron: aaron@email.com] },{29 => [#John: johnsnow @email .com]},{32 => [#Mindy: mindy @email .com],[#Paul: paul @email.com]}
42
+ // {5 => [#Jonathan: jonathan@email.com],[#Aethelwulf: aethelwulf @email.com] },{7 => [#Jack: jack @email .com],[#Athelstan: athelstan @email.com]},{8 => [#Jasmine: jasmine @email .com]},{9 => [#Jake: jake @email .com]},{10 => [#Nathan: nathan @email .com],[#Sargeras: sargeras @email.com]}
44
43
45
- console . log ( hashTable . remove ( 'Donnie ' ) ) ; // true
44
+ console . log ( hashTable . remove ( 'Aethelwulf ' ) ) ; // true
46
45
console . log ( hashTable . toString ( ) ) ;
47
- // {5 => [#Jonathan: jonathan@email.com] },{10 => [#Nathan: nathan @email .com]},{13 => [#Ana: ana @email .com]},{16 => [#Tyrion: tyrion @email .com],[#Aaron: aaron@email.com] },{29 => [#John: johnsnow @email .com]},{32 => [#Mindy: mindy @email .com],[#Paul: paul @email.com]}
46
+ // {5 => [#Jonathan: jonathan@email.com] },{7 => [#Jack: jack @email .com],[#Athelstan: athelstan @email.com]},{8 => [#Jasmine: jasmine @email .com]},{9 => [#Jake: jake @email .com]},{10 => [#Nathan: nathan @email .com],[#Sargeras: sargeras @email.com]}
0 commit comments