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

Task: Create lower-level implementation of LinkedDictionary<TKey, TValue> #11

Open
NightOwl888 opened this issue Jul 31, 2020 · 0 comments
Labels
is:enhancement New feature or request pri:normal up for grabs This issue is open to be worked on by anyone
Milestone

Comments

@NightOwl888
Copy link
Owner

NightOwl888 commented Jul 31, 2020

The LinkedDictionary<TKey, TValue> is a composite type that internally is using a LinkedList<T> and Dictionary<TKey, TValue>. This is a stopgap to get the behavior we need, but we could achieve better performance by using a lower-level hashtable structure to manage the a single collection of items rather than having 2 collections.

The main differences between Dictionary<TKey, TValue> and LinkedDictionary<TKey, TValue> are:

  • LinkedDictionary<TKey, TValue> maintains insertion order across edits
  • LinkedDictionary<TKey, TValue> allows a null key

Update

.NET 9.0 now includes an OrderedDictionary<TKey, TValue> that should provide the correct functionality. It is MIT licensed, so there is no issue with copying it. We need to evaluate the collection to ensure it behaves correctly. It does not support null keys, which is why we will still need to bring it into our project and modify it. I believe we can simply return 0 for a null hash key and run the same lookup code, but if not check the source code of LinkedHashMap.java in Apache Harmony (which is Apache 2.0 licensed code).

We already have tests in J2N.Tests.xUnit to confirm it behaves as expected, however we should also review the tests Microsoft provides for OrderedDictionary<TKey, TValue> to determine whether there are any gaps that we missed.

@NightOwl888 NightOwl888 added is:enhancement New feature or request pri:low up for grabs This issue is open to be worked on by anyone labels Jul 31, 2020
@NightOwl888 NightOwl888 changed the title Create lower-level implementation of LinkedDictionary<TKey, TValue> Task: Create lower-level implementation of LinkedDictionary<TKey, TValue> Aug 14, 2024
@NightOwl888 NightOwl888 added this to the 2.1 milestone Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:enhancement New feature or request pri:normal up for grabs This issue is open to be worked on by anyone
Projects
None yet
Development

No branches or pull requests

1 participant