add GetMin/DeleteMin, GetMax/DeleteMax function to redblacktree #2
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!2
Loading…
Reference in a new issue
No description provided.
Delete branch "master"
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?
hi @emirpasic As redblacktree maintain order of elements, it should be natural to add interface to poll the min and max value from the tree. I've implemented the logic to do so, and I also fixed the wrong test message at here
Please take a look if you have time.
Thank you.
ping @emirpasic
@huydx I've got you brother, thanks for the input. You're right that this feature is very natural for redblack tree. However, I will need to evaluate this idea from a higher architectural point of view, i.e. is this only the case with the redblack tree or should certain datastructures have this defined in their interface or perhaps the container interface even, despite the fact that its computation would be O(n) in some cases. I have not seen that in STL, Ruby, Javascript or Java, they rather provide methods or hooks where you inject this evaluation usually through some type of iterator pattern or evaluation function. So excuse if I'll take longer with this, but it's important that it's implemented the right way across the project, not just for one case.
@huydx
Please check #3
It includes the requested feature (with minor bug fix), documentation and example. If you are happy with that approach, please let me know and I will merge #3 and close this PR.
In short, I did not integrate your changes directly into the red-black tree implementation for two reasons:
However I have exposed the nodes in the red-black tree, so that you can implement your logic by embedding. Please check out the following example of how to extend the red-black tree with your case.
I hope that we both can be happy with this solution, daijoubu desu ka?
Pull request closed