Open
Conversation
jlao
requested changes
Jun 14, 2021
Owner
jlao
left a comment
There was a problem hiding this comment.
Thanks for the contributions. Sorry I didn't look at this sooner. I started a new job earlier this year and it got lost in the mix.
Comment on lines
+91
to
+92
| throw new InvalidOperationException( | ||
| $"GetNodes() parameter n must be greater or equal to 1, but it was {n}"); |
Owner
There was a problem hiding this comment.
I think an ArgumentException would be better here.
Comment on lines
+95
to
+96
| var toReturn = new List<TNode>(); | ||
| var seen = new List<TNode>(); // Faster for small values of n, which is the expected use case. |
Owner
There was a problem hiding this comment.
Is seen needed? Seems like it is the same as toReturn.
| } | ||
| else | ||
|
|
||
| var toReturn = new List<TNode>(); |
Owner
There was a problem hiding this comment.
Seems like we can initialize this list with capacity n to avoid resizing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A common way to implement replicas in a Hash Ring is to find a node on the ring, then return that node plus subsequent nodes. There was no way to do that with HashRing's interface.
I left GetNodes() as unimplemented on BstHashRing since that class only appears in the UnitTests project and it has no test coverage. It seemed like a prototype.
I'm going to be trying HashRing out in my own code this week and might submit further tweaks or changes in this PR or others.