DictionaryList.Core
1.0.0
dotnet add package DictionaryList.Core --version 1.0.0
NuGet\Install-Package DictionaryList.Core -Version 1.0.0
<PackageReference Include="DictionaryList.Core" Version="1.0.0" />
paket add DictionaryList.Core --version 1.0.0
#r "nuget: DictionaryList.Core, 1.0.0"
// Install DictionaryList.Core as a Cake Addin #addin nuget:?package=DictionaryList.Core&version=1.0.0 // Install DictionaryList.Core as a Cake Tool #tool nuget:?package=DictionaryList.Core&version=1.0.0
DictionaryList
The purpose of this code is to implement something like Dictionary<T, U> where T is List<>
I've seen hashcode calculation based implementations, but they were too slow for me
and I decided to use tree-based approach, which's explained below.
Installation
.NET CLI: dotnet add package DictionaryList.Core --version 1.0.0
Example 1
var dict = new DictionaryList<int, int>();
var list1 = new List<int> { 1, 2, 3, 4, 5 };
var list2 = new List<int> { 1, 2, 3, 4, 5, 5, 6 };
dict.Add(list1, 5);
dict.Add(list2, 10);
if (dict.TryGet(list1, out var value1))
Console.WriteLine(value1);
dict.TryGet(list2, out var value2);
Console.WriteLine(value2);
Example 2
var dict = new DictionaryList<int, int>();
var list1 = new List<int> { 1, 2 };
var list2 = new List<int> { 1, 2 };
dict.Add(list1, 5);
dict.Add(list2, 5); // It's fine since Key and Value are the same
dict.Add(list2, 123); // Throws an ArgumentException since Value is different for the same key
How does it work?
Basically it represents all those lists as a tree and stores pairs of list's elements and NULL or if that was the last element, then the value
For example, for those lists, the tree will look like:
Key: { 1, 2, 10 }; Value: 30
Key: { 1, 2, 3 }; Value: 50
Key: { 1, 2, 3, 3 }; Value: 70
Key: { 1, 2, 3, 3, 5 }; Value: 80
Key: { 1, 2, 3, 1 }; Value: 100
todo
Benchmarks
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 274 | 12/31/2021 |