# HG changeset patch # User Brian Neal # Date 1355190158 21600 # Node ID be7f2cd15faf86db535ce8680030a660735ba84a # Parent b75bf8bfa2cfe52b980a28901b4df2cc99792505 Completing Ch 3.4 exercise 4.1. diff -r b75bf8bfa2cf -r be7f2cd15faf ch3ex4.py --- a/ch3ex4.py Mon Dec 10 19:36:47 2012 -0600 +++ b/ch3ex4.py Mon Dec 10 19:42:38 2012 -0600 @@ -42,6 +42,10 @@ for i in range(n): self.maps.append(LinearMap()) + def __len__(self): + """Returns the number of LinearMap buckets in the map.""" + return len(self.maps) + def find_map(self, k): """Finds the right LinearMap for key (k).""" index = hash(k) % len(self.maps) @@ -78,7 +82,7 @@ def add(self, k, v): """Resize the map if necessary and adds the new item.""" - if self.num == len(self.maps.maps): + if self.num == len(self.maps): self.resize() self.maps.add(k, v)