Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit a638b6a

Browse files
author
miachang
committed
deal with sentinel point
1 parent 7ede970 commit a638b6a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pygtrie.py

+7
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,10 @@ def discard(self, key):
13721372
if node and node.children:
13731373
for child in node.children:
13741374
self.discard(child)
1375+
else:
1376+
node.children = {}
1377+
node.value = _SENTINEL
1378+
13751379

13761380

13771381
# Raises KeyError if elem is not contained in the set.
@@ -1384,6 +1388,9 @@ def remove(self, key):
13841388
if node and node.children:
13851389
for child in node.children:
13861390
self.discard(child)
1391+
else:
1392+
node.children = {}
1393+
node.value = _SENTINEL
13871394

13881395
def pop(self):
13891396

0 commit comments

Comments
 (0)