-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
SortedList<TKey, TValue> added GetKeyAtIndex, GetValueAtIndex, and SetValueAtIndex #60520
Conversation
Tagging subscribers to this area: @dotnet/area-system-collections Issue DetailsImplemented set value at index method.
|
Apologies for not looking at this PR, seems like it was missed by the labelling bot. Will get back to you ASAP. |
// Sets the value of the entry at the given index. | ||
public void SetValueAtIndex(int index, TValue value) | ||
{ | ||
if (index< 0 || index >= _size) |
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: indentation
if (index< 0 || index >= _size) | |
if (index < 0 || index >= _size) |
SortedList<TKey, TValue> dictionary = (SortedList<TKey, TValue>)GenericIDictionaryFactory(count); | ||
Assert.All(Enumerable.Range(0, count), index => | ||
{ | ||
Assert.Equal(index, dictionary.IndexOfValue(dictionary.GetValueAtIndex(index))); |
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 assume this would require unique values, but if the test is passing then I guess it's fine.
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.
LGTM, thanks!
Implemented set value at index method.
Exposed get at index methods.
per approved API Proposal #58962