package grenier

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

Install

Dune Dependency

Authors

Maintainers

Sources

grenier-v0.11.tbz
sha256=658e1ad6fc5fdce0871975b3ebcb3ec760248be63cdb9ea965e3121cc7478d77
sha512=d9ff83f1b025f34c22af5921444993df219761dcee8d8cb5a940f266df8677278967434b22314c5c82d5d983e4c94c04cd52c4717d5c1f22fbd3a022631fae1c

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.