@@ -34,33 +34,33 @@ There is a difference between looking something up in the 'trie' and the underly
34
34
The update and delete operations for radix tries can be defined as follows:
35
35
36
36
```
37
- def update(node_hash,path,value):
38
- curnode = db.get(node_hash) if node else [ NULL ] * 17
37
+ def update(node_hash, path, value):
38
+ curnode = db.get(node_hash) if node_hash else [ NULL ] * 17
39
39
newnode = curnode.copy()
40
40
if path == '':
41
41
newnode[-1] = value
42
42
else:
43
- newindex = update(curnode[path[0]],path[1:],value)
43
+ newindex = update(curnode[path[0]], path[1:], value)
44
44
newnode[path[0]] = newindex
45
- db.put(hash(newnode),newnode)
45
+ db.put(hash(newnode), newnode)
46
46
return hash(newnode)
47
47
48
- def delete(node_hash,path):
49
- if node is NULL:
48
+ def delete(node_hash, path):
49
+ if node_hash is NULL:
50
50
return NULL
51
51
else:
52
52
curnode = db.get(node_hash)
53
53
newnode = curnode.copy()
54
54
if path == '':
55
55
newnode[-1] = NULL
56
56
else:
57
- newindex = delete(curnode[path[0]],path[1:])
57
+ newindex = delete(curnode[path[0]], path[1:])
58
58
newnode[path[0]] = newindex
59
59
60
60
if all(x is NULL for x in newnode):
61
61
return NULL
62
62
else:
63
- db.put(hash(newnode),newnode)
63
+ db.put(hash(newnode), newnode)
64
64
return hash(newnode)
65
65
```
66
66
0 commit comments