def METHOD_NAME(self, key, value):
    slot = self.bucket[hashcode(key) % len(self.bucket)]
    #print(f"slot={slot}, index={hashcode(key) % len(self.bucket)}")
    if slot.next == hash_map.NODE_EMPTY:
        slot.next = hash_map.NODE_NULL
    else:
        newidx = self.nextfree()
        #print(f"newidx={newidx}")
        # get the main-slot index
        mainslot = self.bucket[hashcode(slot.key) % len(self.bucket)]
        newslot = self.bucket[newidx]
        #print(f"self={self}\nslot={hashcode(key) % len(self.bucket)} idx_main={hashcode(slot.key) % len(self.bucket)} newidx={newidx}")
        #print(f"insert_p: 1={mainslot} 2={newslot}")
        if mainslot == slot:
            newslot.next = mainslot.next
            mainslot.next = newidx
            slot = newslot
        else:   # link to list
            #print(f"insert_p: 1={mainslot} 2={slot}")
            prev = self.findprev(mainslot, slot)
            prev.next = newidx      # link the previous node
            # copy to new slot
            newslot.key = slot.key
            newslot.value = slot.value
            newslot.next = slot.next
            slot.next = hash_map.NODE_NULL
    slot.key = key
    slot.value = value