Faster.Map 3.0.3.4

.NET Standard 2.0 .NET Framework 4.0
NuGet\Install-Package Faster.Map -Version 3.0.3.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Faster.Map --version 3.0.3.4
<PackageReference Include="Faster.Map" Version="3.0.3.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Faster.Map --version 3.0.3.4
#r "nuget: Faster.Map, 3.0.3.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Faster.Map as a Cake Addin
#addin nuget:?package=Faster.Map&version=3.0.3.4

// Install Faster.Map as a Cake Tool
#tool nuget:?package=Faster.Map&version=3.0.3.4

Faster.Map - A collection of Robinhood hashmaps (FastMap, Map, MultiMap)

The goal of Faster is to provide the fastest dict/set that integrates into the .net scientific ecosystem.

Faster.Map uses the following:

  • Open addressing
  • Linear probing
  • Upper limit on the probe sequence lenght(psl) which is Log2(size)
  • Fibonacci hashing

About

Faster is a small robinhood hashmap with minimal memory overhead and incredibly fast runtime speed. See benchmarks, or try it out yourself. Faster.Map evolved from the fact that C# dictionaries in targetframework 4.0 are terribly slow. So i decided to create my own robinhood hashmap, turns out that this hashmap even performs better than the current dictionary written in .net5.

Get Started

  1. Install nuget package Faster.Map to your project.
dotnet add package Faster.Map

How to use

Faster.Map provides 3 unique hashmaps:

  1. FastMap<Tkey, TValue> is a hashmap which is highly optimized to be used with numerical keys.
  2. Map<Tkey, TValue> is a hashmap which can be used as a replacement to IDicionary.
  3. MultiMap<Tkey, Tvalue> is a hashmap that contains of key-value pairs, while permitting multiple entries with the same key. All key-value pairs are stored in a linear fashion and wont require additional Lists e.g Dictionary<int, List<string>>

Examples

Default Example


private FastMap<uint, uint> _map = new FastMap<uint, uint>(16);     
  _map.Emplace(1, 50); 
  _map.Remove(1);
  _map.Get(1, out var result);
  _map.Update(1, 51);
  
 var result = _map[1];    

Map Example

private Map<uint, uint> _map = new Map<uint, uint>(16);
 _map.Emplace(1, 50); 
 _map.Remove(1);
 _map.Get(1, out var result);
 _map.Update(1, 51);
    

MultiMap Example

private MultiMap<uin,t uint> _multimap = new Map<uint, uint>(16);
 _multimap.Emplace(1, 50); 
 _multimap.Remove(24, 24);
 _multimap.RemoveAll(1);
 _multimap.Update(1, 50);
 _multimap.Get(1, out var result);
 _multimap.GetAll(1);
    

Benchmark

Method N Mean Error StdDev BranchInstructionRetired/Op CacheMisses/Op LLCMisses/Op
FastMap 1000000 1.451 ms 0.0155s 0.0145ms 3015435 175 232
Map 1000000 3.451 ms 0.0102s 0.0095ms 8040841 610 3358
Dictionary 1000000 6.902 ms 0.1305 ms 0.1451 ms 11,075,4822 1050 922
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

This package has 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
3.0.3.4 95 9/20/2022
3.0.3.3 866 5/19/2022
3.0.3.2 90 5/17/2022
3.0.3.1 75 5/17/2022
3.0.3 92 5/17/2022
3.0.2 96 5/15/2022

- minor bug fixes
- use currentProbeCount instead of maxProbeCount