Skip to content
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

Closed
wants to merge 1 commit into from
Closed

make it possible to remove the root node #11

wants to merge 1 commit into from

Conversation

HeavyHorst
Copy link

@HeavyHorst HeavyHorst commented Oct 19, 2016

this should fix issue #4


This change is Reviewable

@turtleDev
Copy link

@derekparker any chance this is going to be merged ?

@msvik
Copy link

msvik commented Dec 20, 2022

@derekparker - can we merge this PR, please?

Copy link
Owner

@derekparker derekparker left a 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 {
Copy link
Owner

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)}
Copy link
Owner

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
Copy link
Owner

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.

@derekparker
Copy link
Owner

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.

@HeavyHorst
Copy link
Author

Feel free to take over the patch :)

@derekparker
Copy link
Owner

#36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants