-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make it possible to remove the root node #11
Conversation
@derekparker any chance this is going to be merged ? |
@derekparker - can we merge this PR, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, just a few changes.
@@ -89,22 +89,33 @@ func (t *Trie) HasKeysWithPrefix(key string) bool { | |||
|
|||
// Removes a key from the trie, ensuring that | |||
// all bitmasks up to root are appropriately recalculated. | |||
func (t *Trie) Remove(key string) { | |||
func (t *Trie) Remove(key string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should change the function signature here as it would break consumers of the library. Any breaking change would require a major version update.
t.size-- | ||
for n := node.Parent(); n != nil; n = n.Parent() { | ||
i++ | ||
|
||
if n == t.root { | ||
t.root = &Node{children: make(map[rune]*Node)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can break from the loop immediately following this assignment.
t.Errorf("Expected 0 keys got %d", len(keys)) | ||
} | ||
|
||
//try to write some data after the trie was purged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space after //
and uppercase first word of comment.
I think the best path forward to merge this is for me to take over the patch and credit the original author somehow, unless @HeavyHorst is still willing to update this patch. Sorry for the extreme delay in reviewing this change. |
Feel free to take over the patch :) |
this should fix issue #4
This change is