Skip to content

Latest commit

 

History

History
35 lines (30 loc) · 866 Bytes

README.md

File metadata and controls

35 lines (30 loc) · 866 Bytes

ocaml-cmph

Ocaml bindings for C Minimal Perfect Hashing Library (CMPH)

Online documentation

Usage

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