The Closest | Btree #72
No reviewers
Labels
No labels
bug
discussion
documentation
duplicate
ignore
new feature
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
golibs/gms-gods!72
Loading…
Reference in a new issue
No description provided.
Delete branch "closest"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This add a function to be able to get the values next to the pointed one.
Let me know if this is correctly done.
Best regards
@alexandrestein I think the same comment/question to you applies here as well, read on #82
edit: actually just noted that you added more functionality than in the other case, so let me check this out...
@ -98,0 +115,4 @@func (tree *Tree) getClosest(key interface{}, keyWanted bool) (prev, next interface{}, found bool) {// The first part of the function is almost a clone of tree.searchRecursivelyif tree.Empty() {return nil, nil, falsereturning 3 params is a bit hard to handle for consumers of gods. i'd rather split this function into Ceiling and Floor which has also been added to RedBlackTree/TreeMap. we could add a GetClosest that would simply return two parameters (key-value pair) of the closest node be it ceiling or floow... otherwise nil if the tree is empty.
@ -98,0 +149,4 @@// Returns the interator at the right positionreturn Iterator{tree: tree,node: node,IteratorAt is an interesting idea also asked for by https://github.com/emirpasic/gods/issues/66
@ -98,0 +156,4 @@}// The key is not in the node but this is a leaf node.// This means that the key is not in the tree and the returned pointer willNot sure if search is the correct function to call.
i think you wanted the searchRecursively function
Pull request closed