mirror of
https://github.com/jlengrand/Coding4Interviews.git
synced 2026-03-10 08:11:24 +00:00
Adds custom size of hash map table
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user