https://github.com/jfeser/ocaml-cmph
Ocaml bindings for C Minimal Perfect Hashing Library (CMPH)
https://github.com/jfeser/ocaml-cmph
hashing mphf ocaml perfect-hash
Last synced: 8 months ago
JSON representation
Ocaml bindings for C Minimal Perfect Hashing Library (CMPH)
- Host: GitHub
- URL: https://github.com/jfeser/ocaml-cmph
- Owner: jfeser
- License: mit
- Created: 2017-12-25T00:47:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-09-29T21:32:12.000Z (over 5 years ago)
- Last Synced: 2025-03-10T18:54:15.001Z (over 1 year ago)
- Topics: hashing, mphf, ocaml, perfect-hash
- Language: OCaml
- Size: 52.3 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# ocaml-cmph
Ocaml bindings for C Minimal Perfect Hashing Library ([CMPH](http://cmph.sourceforge.net/))
[Online documentation](https://jfeser.github.io/ocaml-cmph/cmph/index.html)
# Usage
```ocaml
open Printf
open Cmph
let () =
let keys = [
"aaaaaaaaaa"; "bbbbbbbbbb"; "cccccccccc"; "dddddddddd"; "eeeeeeeeee";
"ffffffffff"; "gggggggggg"; "hhhhhhhhhh"; "iiiiiiiiii"; "jjjjjjjjjj"
] in
let keyset = KeySet.of_list keys in
let config = Config.create keyset in
let hash = Hash.create config in
List.iter (fun k -> eprintf "key:%s -- hash:%d\n" k (Hash.hash hash k)) keys
```
Outputs:
```
key:aaaaaaaaaa -- hash:0
key:bbbbbbbbbb -- hash:1
key:cccccccccc -- hash:2
key:dddddddddd -- hash:3
key:eeeeeeeeee -- hash:4
key:ffffffffff -- hash:5
key:gggggggggg -- hash:6
key:hhhhhhhhhh -- hash:7
key:iiiiiiiiii -- hash:8
key:jjjjjjjjjj -- hash:9
```