Adds custom size of hash map table

This commit is contained in:
Julien Lengrand-Lambert
2013-11-21 11:40:29 +01:00
parent cccda38920
commit 702f8999b3
2 changed files with 10 additions and 1 deletions

View File

@@ -5,7 +5,8 @@ HashMap Table Implementation
"""
class HashMap():
def __init__(self):
def __init__(self, hash_size=513):
self._hash_size = hash_size
self._size = 0
def size(self):

View File

@@ -11,6 +11,14 @@ import unittest
class test_hash_map(unittest.TestCase):
def test_hash_size(self):
hm = HashMap()
self.assertEqual(hm._hash_size, 513)
hm = HashMap(1025)
self.assertEqual(hm._hash_size, 1025)
def test_size(self):
hm = HashMap()
self.assertEqual(hm.size(), 0)