package grenier

  1. Overview
  2. Docs
A collection of various algorithms in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

grenier-0.15.tbz
sha256=dec7f84b9e93d5825f10c7dea84d5a74d7365ede45664ae63c26b5e8045c1c44
sha512=b8aa1569c2e24b89674d1b34de34cd1798896bb6a53aa5a1287f68cee880125e6b687f66ad73da9069a01cc3ece1f0684f48328b099d43529bff736b772c8fd8

doc/src/grenier.jmphash/jmphash.ml.html

Source file jmphash.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
let hash_k = Int64.(shift_left 1L 31)

let rec jmp_hash j n key =
  let key = Int64.(succ (mul key 2862933555777941757L)) in
  let key' = Int64.(succ (shift_right_logical key 33)) in
  let a = Int64.succ j in
  let j' = Int64.(div (mul a hash_k) key') in
  if j' >= Int64.of_int n then
    j
  else
    jmp_hash j' n key

let host ~hosts key =
  Int64.to_int (jmp_hash 0L hosts key)
OCaml

Innovation. Community. Security.