💾 Archived View for gmi.noulin.net › markdown › perfecthash_README.md captured on 2023-07-10 at 18:18:51.

View Raw

More Information

-=-=-=-=-=-=-

# Sheepy
This is a sheepy package for [sheepy](https://spartatek.se/r/sheepy/file/README.md.html) and using [libsheepy](https://spartatek.se/r/libsheepy/file/README.md.html)

# perfecthash

[What is a perfect hash function?](https://en.wikipedia.org/wiki/Perfect_hash_function)

`genHanov` generates a perfect hash function C source code given a list of keys in a text file.
`genHanov` expects one key per line.

genHanov is inspired by the Steve Hanov implementation of the Dr Daoud perfect hash algorithm.

# Usage

Install with spm: `spm -g install perfecthash`

Generate a perfect hash function:

genHanov keys.txt


The generated code depends on the crc package, to install it:
`spm install crc`

Just running `genHanov` prints the help.

To configure `genHanov`, create a `hanovConfig.yml` file with this content:

---

type: hanovt

perfectHashData: perfectHash

keysArray: keys

funcScope: static inline

hashFunc: hanovHash

lookupFunc: hanovLookup

findFunc: hanovFind