summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-perfect-hash.h
blob: 50553eee735b03732ec9891209a3baebb89f0f71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include "../core/slang-list.h"
#include "../core/slang-string.h"

namespace Slang
{

struct HashParams
{
    List<UInt32> saltTable;
    List<String> destTable;
};

enum class HashFindResult
{
    Success,
    NonUniqueKeys,
    UnavoidableHashCollision,
};

// Calculate a minimal perfect hash of a list of input strings
HashFindResult minimalPerfectHash(const List<String>& ss, HashParams& hashParams);

String perfectHashToEmbeddableCpp(
    const HashParams& hashParams,
    const UnownedStringSlice& valueType,
    const UnownedStringSlice& funcName,
    const List<String>& values);

} // namespace Slang