class hashmapbase(mapbase) """abstract base class for map using hash-table with mad compression "" def init (selfcap= = ) """create an empty hash-table map "" self table cap none number of entries in the map self prime for mad compression self prime scale from to - for mad self scale randrange( - shift from to - for mad self shift randrange( def hash function(selfk) return (hash(kself scale self shiftself prime len(self table def len (self) return self def getitem (selfk) self hash function(kmay raise keyerror return self bucket getitem(jk def setitem (selfkv) self hash function(ksubroutine maintains self self bucket setitem(jkvkeep load factor < if self len(self table/ number ^ is often prime self resize( len(self table def delitem (selfk) self hash function(kmay raise keyerror self bucket delitem(jk self - resize bucket array to capacity def resize(selfc) old list(self items)use iteration to record existing items then reset table to desired capacity self table [nonen recomputed during subsequent adds self for ( ,vin old self[kv reinsert old key-value pair code fragment base class for our hash table implementationsextending our mapbase class from code fragment