Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
new_node = CollisionNode(
self.size + 2, hash, new_array, mutid)
return new_node, True
val_idx = key_idx + 1
if self.array[val_idx] is val:
return self, False
if mutid and mutid == self.mutid:
self.array[val_idx] = val
return self, False
else:
new_array = self.array.copy()
new_array[val_idx] = val
return CollisionNode(self.size, hash, new_array, mutid), False
else:
new_node = BitmapNode(
2, map_bitpos(self.hash, shift), [None, self], mutid)
return new_node.assoc(shift, hash, key, val, mutid)
else:
assert key_idx == 2
new_array = [self.array[0], self.array[1]]
new_node = BitmapNode(
2, map_bitpos(hash, shift), new_array, mutid)
return W_NEWNODE, new_node
new_array = self.array[:key_idx]
new_array.extend(self.array[key_idx + 2:])
if mutid and mutid == self.mutid:
self.array = new_array
self.size -= 2
return W_NEWNODE, self
else:
new_node = CollisionNode(
self.size - 2, self.hash, new_array, mutid)
return W_NEWNODE, new_node
if key == key_or_null:
if val is val_or_node:
return self, False
if mutid and mutid == self.mutid:
self.array[val_idx] = val
return self, False
else:
ret = self.clone(mutid)
ret.array[val_idx] = val
return ret, False
existing_key_hash = map_hash(key_or_null)
if existing_key_hash == hash:
sub_node = CollisionNode(
4, hash, [key_or_null, val_or_node, key, val], mutid)
else:
sub_node = BitmapNode(0, 0, [], mutid)
sub_node, _ = sub_node.assoc(
shift + 5, existing_key_hash,
key_or_null, val_or_node,
mutid)
sub_node, _ = sub_node.assoc(
shift + 5, hash, key, val,
mutid)
if mutid and mutid == self.mutid:
self.array[key_idx] = None
self.array[val_idx] = sub_node
return self, True
else:
def assoc(self, shift, hash, key, val, mutid):
if hash == self.hash:
key_idx = self.find_index(key)
if key_idx == -1:
new_array = self.array.copy()
new_array.append(key)
new_array.append(val)
if mutid and mutid == self.mutid:
self.size += 2
self.array = new_array
return self, True
else:
new_node = CollisionNode(
self.size + 2, hash, new_array, mutid)
return new_node, True
val_idx = key_idx + 1
if self.array[val_idx] is val:
return self, False
if mutid and mutid == self.mutid:
self.array[val_idx] = val
return self, False
else:
new_array = self.array.copy()
new_array[val_idx] = val
return CollisionNode(self.size, hash, new_array, mutid), False
else: