Exit out of loop once key is found/removed from hash map

This commit is contained in:
Donne Martin 2016-06-12 23:16:06 -04:00
parent 38fa7aff46
commit 4c45be5a9e
2 changed files with 12 additions and 11 deletions

View File

@ -196,21 +196,21 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 2", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python2" "name": "python3"
}, },
"language_info": { "language_info": {
"codemirror_mode": { "codemirror_mode": {
"name": "ipython", "name": "ipython",
"version": 2 "version": 3
}, },
"file_extension": ".py", "file_extension": ".py",
"mimetype": "text/x-python", "mimetype": "text/x-python",
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython2", "pygments_lexer": "ipython3",
"version": "2.7.10" "version": "3.5.0"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -149,7 +149,8 @@
" hash_index = self.hash_function(key)\n", " hash_index = self.hash_function(key)\n",
" for i, item in enumerate(self.table[hash_index]):\n", " for i, item in enumerate(self.table[hash_index]):\n",
" if item.key == key:\n", " if item.key == key:\n",
" del self.table[hash_index][i]" " del self.table[hash_index][i]\n",
" return"
] ]
}, },
{ {
@ -253,21 +254,21 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 2", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python2" "name": "python3"
}, },
"language_info": { "language_info": {
"codemirror_mode": { "codemirror_mode": {
"name": "ipython", "name": "ipython",
"version": 2 "version": 3
}, },
"file_extension": ".py", "file_extension": ".py",
"mimetype": "text/x-python", "mimetype": "text/x-python",
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython2", "pygments_lexer": "ipython3",
"version": "2.7.10" "version": "3.5.0"
} }
}, },
"nbformat": 4, "nbformat": 4,