ocaml-containers/dev/containers/CCHash/index.html
2021-05-18 21:54:13 +00:00

2 lines
No EOL
14 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>CCHash (containers.CCHash)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.2"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> <a href="../index.html">containers</a> &#x00BB; CCHash</nav><h1>Module <code>CCHash</code></h1><h2 id="hash-combinators"><a href="#hash-combinators" class="anchor"></a>Hash combinators</h2><p>The API of this module is stable as per semantic versioning, like the rest of containers. However the exact implementation of hashing function can change and should not be relied on (i.e. hashing a value always returns the same integer <b>within a run of a program</b>, not across versions of OCaml and Containers).</p><nav class="toc"><ul><li><a href="#definitions">Definitions</a></li><li><a href="#base-hash-combinators">Base hash combinators</a></li><li><a href="#iterators">Iterators</a></li></ul></nav></header><section><header><h3 id="definitions"><a href="#definitions" class="anchor"></a>Definitions</h3></header><dl><dt class="spec type" id="type-hash"><a href="#type-hash" class="anchor"></a><code><span class="keyword">type</span> hash</code><code> = int</code></dt><dd><p>A hash value is a positive integer.</p></dd></dl><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> <span>'a t</span></code><code> = <span class="type-var">'a</span> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a></code></dt><dd><p>A hash function for values of type <code>'a</code>.</p></dd></dl><dl><dt class="spec value" id="val-const"><a href="#val-const" class="anchor"></a><code><span class="keyword">val</span> const : <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <span><span class="type-var">_</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p><code>const h</code> hashes any value into <code>h</code>. Use with caution!.</p></dd></dl><dl><dt class="spec value" id="val-const0"><a href="#val-const0" class="anchor"></a><code><span class="keyword">val</span> const0 : <span><span class="type-var">_</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Always return 0. Useful for ignoring elements. Example: <code>Hash.(pair string const0)</code> will map pairs <code>(&quot;a&quot;, 1)</code> and <code>(&quot;a&quot;, 2)</code> to the same hash, but not the same as <code>(&quot;b&quot;, 1)</code>.</p><dl><dt>since</dt><dd>1.5</dd></dl></dd></dl><dl><dt class="spec value" id="val-int"><a href="#val-int" class="anchor"></a><code><span class="keyword">val</span> int : <span>int <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-bool"><a href="#val-bool" class="anchor"></a><code><span class="keyword">val</span> bool : <span>bool <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-char"><a href="#val-char" class="anchor"></a><code><span class="keyword">val</span> char : <span>char <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-int32"><a href="#val-int32" class="anchor"></a><code><span class="keyword">val</span> int32 : <span>int32 <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-int64"><a href="#val-int64" class="anchor"></a><code><span class="keyword">val</span> int64 : <span>int64 <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-nativeint"><a href="#val-nativeint" class="anchor"></a><code><span class="keyword">val</span> nativeint : <span>nativeint <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-slice"><a href="#val-slice" class="anchor"></a><code><span class="keyword">val</span> slice : string <span>&#45;&gt;</span> int <span>&#45;&gt;</span> <span>int <a href="index.html#type-t">t</a></span></code></dt><dd><p><code>slice s i len state</code> hashes the slice <code>i, …, i+len-1</code> of <code>s</code> into <code>state</code>.</p></dd></dl><dl><dt class="spec value" id="val-bytes"><a href="#val-bytes" class="anchor"></a><code><span class="keyword">val</span> bytes : <span>bytes <a href="index.html#type-t">t</a></span></code></dt><dd><p>Hash a byte array.</p><dl><dt>since</dt><dd>NEXT_RELEASE</dd></dl></dd></dl><dl><dt class="spec value" id="val-string"><a href="#val-string" class="anchor"></a><code><span class="keyword">val</span> string : <span>string <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-list"><a href="#val-list" class="anchor"></a><code><span class="keyword">val</span> list : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> list</span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-array"><a href="#val-array" class="anchor"></a><code><span class="keyword">val</span> array : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> array</span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-opt"><a href="#val-opt" class="anchor"></a><code><span class="keyword">val</span> opt : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> option</span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-pair"><a href="#val-pair" class="anchor"></a><code><span class="keyword">val</span> pair : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'b</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>)</span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-triple"><a href="#val-triple" class="anchor"></a><code><span class="keyword">val</span> triple : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'b</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'c</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span> * <span class="type-var">'c</span>)</span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-quad"><a href="#val-quad" class="anchor"></a><code><span class="keyword">val</span> quad : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'b</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'c</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'d</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span> * <span class="type-var">'c</span> * <span class="type-var">'d</span>)</span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-if_"><a href="#val-if_" class="anchor"></a><code><span class="keyword">val</span> if_ : bool <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Decide which hash function to use depending on the boolean.</p></dd></dl><dl><dt class="spec value" id="val-poly"><a href="#val-poly" class="anchor"></a><code><span class="keyword">val</span> poly : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p><code>poly x</code> is <code>Hashtbl.hash x</code>. The regular polymorphic hash function.</p></dd></dl><dl><dt class="spec value" id="val-list_comm"><a href="#val-list_comm" class="anchor"></a><code><span class="keyword">val</span> list_comm : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> list</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Commutative version of <a href="index.html#val-list"><code>list</code></a>. Lists that are equal up to permutation will have the same hash.</p><dl><dt>since</dt><dd>1.0</dd></dl></dd></dl><dl><dt class="spec value" id="val-array_comm"><a href="#val-array_comm" class="anchor"></a><code><span class="keyword">val</span> array_comm : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> array</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Commutative version of <a href="index.html#val-array"><code>array</code></a>. Arrays that are equal up to permutation will have the same hash.</p><dl><dt>since</dt><dd>1.0</dd></dl></dd></dl></section><section><header><h3 id="base-hash-combinators"><a href="#base-hash-combinators" class="anchor"></a>Base hash combinators</h3></header><dl><dt class="spec value" id="val-combine"><a href="#val-combine" class="anchor"></a><code><span class="keyword">val</span> combine : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <span class="type-var">'a</span> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a></code></dt><dt class="spec value" id="val-combine2"><a href="#val-combine2" class="anchor"></a><code><span class="keyword">val</span> combine2 : <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a></code></dt><dt class="spec value" id="val-combine3"><a href="#val-combine3" class="anchor"></a><code><span class="keyword">val</span> combine3 : <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a></code></dt><dt class="spec value" id="val-combine4"><a href="#val-combine4" class="anchor"></a><code><span class="keyword">val</span> combine4 : <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a></code></dt><dt class="spec value" id="val-combine5"><a href="#val-combine5" class="anchor"></a><code><span class="keyword">val</span> combine5 : <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a></code></dt><dd><dl><dt>since</dt><dd>2.1</dd></dl></dd></dl><dl><dt class="spec value" id="val-combine6"><a href="#val-combine6" class="anchor"></a><code><span class="keyword">val</span> combine6 : <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a> <span>&#45;&gt;</span> <a href="index.html#type-hash">hash</a></code></dt><dd><dl><dt>since</dt><dd>2.1</dd></dl></dd></dl></section><section><header><h3 id="iterators"><a href="#iterators" class="anchor"></a>Iterators</h3></header><dl><dt class="spec type" id="type-iter"><a href="#type-iter" class="anchor"></a><code><span class="keyword">type</span> <span>'a iter</span></code><code> = <span>(<span class="type-var">'a</span> <span>&#45;&gt;</span> unit)</span> <span>&#45;&gt;</span> unit</code></dt><dt class="spec type" id="type-gen"><a href="#type-gen" class="anchor"></a><code><span class="keyword">type</span> <span>'a gen</span></code><code> = unit <span>&#45;&gt;</span> <span><span class="type-var">'a</span> option</span></code></dt></dl><dl><dt class="spec value" id="val-seq"><a href="#val-seq" class="anchor"></a><code><span class="keyword">val</span> seq : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> Stdlib.Seq.t</span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-iter"><a href="#val-iter" class="anchor"></a><code><span class="keyword">val</span> iter : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> <a href="index.html#type-iter">iter</a></span> <a href="index.html#type-t">t</a></span></code></dt><dt class="spec value" id="val-gen"><a href="#val-gen" class="anchor"></a><code><span class="keyword">val</span> gen : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span><span class="type-var">'a</span> <a href="index.html#type-gen">gen</a></span> <a href="index.html#type-t">t</a></span></code></dt></dl></section></div></body></html>