From c44e74918af79cb45532cc7423bdcb3a853f27fd Mon Sep 17 00:00:00 2001 From: loiane <loianeg@gmail.com> Date: Mon, 21 Aug 2017 09:57:03 -0300 Subject: [PATCH 1/3] fixes #23 --- chapter07/07-HashCollisionLinearProbing.js | 9 +++++++++ chapter07/08-UsingHashCollisionLinearProbing.js | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/chapter07/07-HashCollisionLinearProbing.js b/chapter07/07-HashCollisionLinearProbing.js index 38b07c0f..4b1172be 100644 --- a/chapter07/07-HashCollisionLinearProbing.js +++ b/chapter07/07-HashCollisionLinearProbing.js @@ -53,6 +53,15 @@ function HashLinearProbing(){ return table[index].value; } } + } else { //search for possible deleted value + var index = ++position; + while (table[index] == undefined || index == table.length || + (table[index] !== undefined && table[index] && table[index].key !== key)){ + index++; + } + if (table[index] && table[index].key === key) { + return table[index].value; + } } return undefined; }; diff --git a/chapter07/08-UsingHashCollisionLinearProbing.js b/chapter07/08-UsingHashCollisionLinearProbing.js index 902384ee..36a33e61 100644 --- a/chapter07/08-UsingHashCollisionLinearProbing.js +++ b/chapter07/08-UsingHashCollisionLinearProbing.js @@ -26,4 +26,12 @@ console.log('**** Remove **** '); hashLinearProbing.remove('Gandalf'); console.log(hashLinearProbing.get('Gandalf')); +hashLinearProbing.print(); + +console.log('**** Remove Test 2 **** '); +console.log('Removing Jonathan', hashLinearProbing.remove('Jonathan')); +console.log('**** Print **** '); +hashLinearProbing.print(); +console.log('Get Jamie', hashLinearProbing.get('Jamie')); +console.log('**** Print **** '); hashLinearProbing.print(); \ No newline at end of file From 10b24fd4a3ec01aa8db5a5bffb29e55559647dae Mon Sep 17 00:00:00 2001 From: loiane <loianeg@gmail.com> Date: Thu, 7 Sep 2017 09:18:28 -0300 Subject: [PATCH 2/3] gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6fee6d3a..2458e8b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea/* -*.log \ No newline at end of file +*.log +node_modules +coverage From f06567601501477cb470a8e0b59cfb9f36d8d19d Mon Sep 17 00:00:00 2001 From: Loiane Groner <loianeg@gmail.com> Date: Mon, 20 Nov 2017 13:09:10 -0200 Subject: [PATCH 3/3] Update 14-ES6ParameterHandling.js --- chapter01/14-ES6ParameterHandling.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter01/14-ES6ParameterHandling.js b/chapter01/14-ES6ParameterHandling.js index 4645f2a7..af23585c 100644 --- a/chapter01/14-ES6ParameterHandling.js +++ b/chapter01/14-ES6ParameterHandling.js @@ -14,7 +14,7 @@ function sum2 (x, y, z) { z = 3; return x + y + z; }; -console.log(sum2(4,2)); //outpus 10 +console.log(sum2(4,2)); //outpus 9 //******* EcmaScript 6: spread operator ('...') var params = [3, 4, 5];