Code Duplication    Length = 16-17 lines in 2 locations

pyalgs/data_structures/commons/hashed_map.py 1 location

@@ 92-108 (lines=17) @@
89
            x = x.next_node
90
        return None
91
92
    def delete(self, key):
93
        i = self.hash(key)
94
        x = self.id[i]
95
        prev_node = None
96
        while x is not None:
97
            if util.cmp(x.key, key) == 0:
98
                value = x.value
99
                next_node = x.next_node
100
                self.N -= 1
101
                if prev_node is not None:
102
                    prev_node.next_node = next_node
103
                if self.id[i] == x:
104
                    self.id[i] = None
105
                return value
106
            prev_node = x
107
            x = x.next_node
108
        return None
109
110
    def put(self, key, value):
111
        if key is None:

pyalgs/data_structures/commons/hashed_set.py 1 location

@@ 84-99 (lines=16) @@
81
            x = x.next_node
82
        return False
83
84
    def delete(self, key):
85
        i = self.hash(key)
86
        x = self.id[i]
87
        prev_node = None
88
        while x is not None:
89
            if util.cmp(x.key, key) == 0:
90
                next_node = x.next_node
91
                self.N -= 1
92
                if prev_node is not None:
93
                    prev_node.next_node = next_node
94
                if self.id[i] == x:
95
                    self.id[i] = None
96
                return True
97
            prev_node = x
98
            x = x.next_node
99
        return False
100
101
    def add(self, key):
102
        if key is None: