Tiny perfect hash library for dotnet. This is an implementation of the CHD algorithm
This project is available as a NuGet package
var strings = Enumerable.Range(0, 6).Select(x => $"str{x}").ToArray();
var settings = new PhfSettings {ItemsPerBucket = 4, Alpha = 80, Seed = 31337, NoDivision = true};
var hashFunction = PerfectHashFunction.Create(strings, settings);
foreach (var str in strings)
Console.WriteLine($"{str} - {hashFunction.Evaluate(str)}");
str0 - 0
str1 - 4
str2 - 6
str3 - 3
str4 - 2
str5 - 5
- You can serialize created
PerfectHashFunction
for the future usage PhfSettings
has default values for all properties