ImmutableHashDictionary 1.0.0

An implementation of IImmutableDictionary<TKey, TValue> that maintains O(1) value lookup, at the cost of mutation performance.

Install-Package ImmutableHashDictionary -Version 1.0.0
dotnet add package ImmutableHashDictionary --version 1.0.0
<PackageReference Include="ImmutableHashDictionary" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ImmutableHashDictionary --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ImmutableHashDictionary

An implementation of IImmutableDictionary&lt;TKey, TValue&gt; that maintains O(1) value lookup, at the cost of mutation performance.

A good choice when working with dictionaries that remain moderately small and/or that are accessed for reading far more frequently than for modification.

This package also includes an ImmutableHashDictionary static factory class and an ImmutableHashDictionary&lt;TKey, TValue&gt;.Builder class that provide API''s identical to the ImmutableDictionary and ImmutableDictionary&lt;TKey, TValue&gt;.Builder classes.

Targets .NET Standard 2.0.

C#8 (Nullable Reference Types) Compliant.

Benchmarks

The following benchmarks demonstrate the performance advantages and disadvantages of the ImmutableHashDictionary&lt;TKey, TValue&gt; class over the Dictionary&lt;TKey, TValue&gt; and ImmutableDictionary&lt;TKey, TValue&gt; classes.

The performance of value lookup by key for ImmutableHashDictionary&lt;TKey, TValue&gt; is, as desired, on par with that of Dictionary&lt;TKey, TValue&gt; and far exceeds that of ImmutableDictionary&lt;TKey, TValue&gt;, even for very large collections.

The performance of single add and remove operations for ImmutableHashDictionary&lt;TKey, TValue&gt; is, as expected, comparable to that of ImmutableDictionary&lt;TKey, TValue&gt; for smaller collections, but does not scale well (O(N) vs O(log N)).

Interestingly, the performance of ranged add and remove operations for ImmutableHashDictionary&lt;TKey, TValue&gt; tends to far exceed that of ImmutableDictionary&lt;TKey, TValue&gt;, and tends to be comparable to that of Dictionary&lt;TKey, TValue&gt; suggesting that the performance costs of mutating an ImmutableHashDictionary can be mitigated by performing mutations in batches, as much as possible.

ImmutableHashDictionary

An implementation of IImmutableDictionary&lt;TKey, TValue&gt; that maintains O(1) value lookup, at the cost of mutation performance.

A good choice when working with dictionaries that remain moderately small and/or that are accessed for reading far more frequently than for modification.

This package also includes an ImmutableHashDictionary static factory class and an ImmutableHashDictionary&lt;TKey, TValue&gt;.Builder class that provide API''s identical to the ImmutableDictionary and ImmutableDictionary&lt;TKey, TValue&gt;.Builder classes.

Targets .NET Standard 2.0.

C#8 (Nullable Reference Types) Compliant.

Benchmarks

The following benchmarks demonstrate the performance advantages and disadvantages of the ImmutableHashDictionary&lt;TKey, TValue&gt; class over the Dictionary&lt;TKey, TValue&gt; and ImmutableDictionary&lt;TKey, TValue&gt; classes.

The performance of value lookup by key for ImmutableHashDictionary&lt;TKey, TValue&gt; is, as desired, on par with that of Dictionary&lt;TKey, TValue&gt; and far exceeds that of ImmutableDictionary&lt;TKey, TValue&gt;, even for very large collections.

The performance of single add and remove operations for ImmutableHashDictionary&lt;TKey, TValue&gt; is, as expected, comparable to that of ImmutableDictionary&lt;TKey, TValue&gt; for smaller collections, but does not scale well (O(N) vs O(log N)).

Interestingly, the performance of ranged add and remove operations for ImmutableHashDictionary&lt;TKey, TValue&gt; tends to far exceed that of ImmutableDictionary&lt;TKey, TValue&gt;, and tends to be comparable to that of Dictionary&lt;TKey, TValue&gt; suggesting that the performance costs of mutating an ImmutableHashDictionary can be mitigated by performing mutations in batches, as much as possible.

Release Notes

Initial release.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.0 159 1/21/2019