Faster.Map 4.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Faster.Map --version 4.0.0
NuGet\Install-Package Faster.Map -Version 4.0.0
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.
<PackageReference Include="Faster.Map" Version="4.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Faster.Map --version 4.0.0
#r "nuget: Faster.Map, 4.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. 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=4.0.0

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

Faster.Map - A collection of Robin-hood hashmaps (FastMap, DenseMapSIMD and DenseMap)

The goal of Faster is to provide a collection of incredible fast hashmaps that integrates into the .net framework.

About

Faster.Map is a collection of hashmaps with minimal memory overhead and incredibly fast runtime speed. See benchmarks, or try it out yourself. Faster 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 .net7.

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 has incredible performance, will only work with numerical keys. Keys need to be unique. Won`t handle hashcollisions

  2. DenseMap<Tkey, TValue> is a hashmap which can be used as a replacement to IDicionary. Default loadfactor is 0.5

  3. DenseMapSIMD<Tkey, TValue> is a next level hashmap using simd intructions. The default loadfactor is 0.9. This allows us to store 15% more entries than a dictionary while maintaining incredible speed. This hashmap is fast and i mean mindblowing fast. DenseMapSIMD wont cache hashcodes, using types like strings actually need a wrapper that caches the hashcode. Hence using a slow hash fuction will result in a slow hashmap.

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];    

DenseMap Example

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

#DenseMapSIMD

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

Benchmark

Retrieving a million random generated keys

Method Mean Error StdDev
SlimDictionary 19.305 ms 0.1827 ms 0.1620 ms
Dictionary 23.199 ms 0.4628 ms 0.5144 ms
DenseMapSIMD 8.915 ms 0.1328 ms 0.1109 ms
DenseMap 15.714 ms 0.3012 ms 0.2958 ms
FastMap 11.608 ms 0.1197 ms 0.1061 ms

Adding a million keys

Method Mean Error StdDev
DictionarySlim 21.34 ms 0.424 ms 0.904 ms
Dictionary 17.17 ms 0.339 ms 0.785 ms
DenseMapSIMD 9.372 ms 0.1852 ms 0.3740 ms
FastMap 14.88 ms 0.292 ms 0.437 ms
DenseMap 26.81 ms 0.689 ms 2.011 ms
Method Mean Error StdDev
UpdateSlim 21.01 ms 0.372 ms 0.348 ms
Dictionary 28.37 ms 0.558 ms 0.835 ms
DenseMapSIMD 13.25 ms 0.208 ms 0.195 ms
FastMap 10.28 ms 0.152 ms 0.135 ms
DenseMap 15.95 ms 0.127 ms 0.113 ms

Removing a million keys

Method Mean Error StdDev
SlimDictionary 5.867 ms 0.1152 ms 0.2076 ms
Dictionary 7.636 ms 0.1703 ms 0.4994 ms
FastMap 21.410 ms 0.5362 ms 1.5297 ms
DenseMap 37.651 ms 0.9171 ms 2.6752 ms
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Faster.Map:

Package Downloads
Faster.Ioc

Package Description

UPSRestApi

UpsRestApi library for .Net used to access UPS API Catalog to browse products and view documentation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.0.4 98 4/16/2024
5.0.3 433 11/18/2023
5.0.2 167 10/29/2023
5.0.1 99 10/29/2023
5.0.0 128 10/28/2023
4.2.1 265 9/2/2023
4.2.0 1,402 4/24/2023
4.1.6 210 4/24/2023
4.1.5 318 3/19/2023
4.1.4 314 3/14/2023
4.1.3 264 3/14/2023
4.1.2 237 3/14/2023
4.1.1 832 3/10/2023
4.1.0 278 3/9/2023
4.0.9 264 3/9/2023
4.0.8 256 3/9/2023
4.0.7 289 3/6/2023
4.0.6 308 3/3/2023
4.0.5 297 3/1/2023
4.0.4 370 2/24/2023
4.0.3 331 2/23/2023
4.0.2 1,103 1/7/2023
4.0.1 364 1/6/2023
4.0.0 349 1/4/2023
3.0.4.2 700 12/22/2022
3.0.3.9 1,009 12/9/2022
3.0.3.8 725 11/8/2022
3.0.3.7 484 10/27/2022
3.0.3.6 501 10/18/2022
3.0.3.5 403 10/18/2022
3.0.3.4 1,058 9/20/2022
3.0.3.3 1,225 5/19/2022
3.0.3.2 453 5/17/2022
3.0.3.1 446 5/17/2022
3.0.3 448 5/17/2022
3.0.2 459 5/15/2022

Add DensemapSIMD to nuget package
    increase verssion to 4.0.0