ocaml-containers/2.8/containers/CCHeap/Make_from_compare/index.html
2019-12-14 17:27:18 -06:00

2 lines
No EOL
18 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>Make_from_compare (containers.CCHeap.Make_from_compare)</title><link rel="stylesheet" href="../../../odoc.css"/><meta charset="utf-8"/><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; <a href="../index.html">CCHeap</a> &#x00BB; Make_from_compare</nav><h1>Module <code>CCHeap.Make_from_compare</code></h1><p>A convenient version of <code>Make</code> that take a <code>TOTAL_ORD</code> instead of a partially ordered module. It allow to directly pass modules that implement <code>compare</code> without implementing <code>leq</code> explicitly</p><nav class="toc"><ul><li><a href="#conversions">Conversions</a></li></ul></nav></header><h3 class="heading">Parameters</h3><ul><li><code><a href="argument-1-E/index.html">E</a> : <a href="../index.html#module-type-TOTAL_ORD">TOTAL_ORD</a></code></li></ul><h3 class="heading">Signature</h3><dl><dt class="spec type" id="type-elt"><a href="#type-elt" class="anchor"></a><code><span class="keyword">type</span> elt</code><code> = <a href="argument-1-E/index.html#type-t">E.t</a></code></dt><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> t</code></dt></dl><dl><dt class="spec value" id="val-empty"><a href="#val-empty" class="anchor"></a><code><span class="keyword">val</span> empty : <a href="index.html#type-t">t</a></code></dt><dd><p>Empty heap.</p></dd></dl><dl><dt class="spec value" id="val-is_empty"><a href="#val-is_empty" class="anchor"></a><code><span class="keyword">val</span> is_empty : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><p>Is the heap empty?</p></dd></dl><dl><dt class="spec exception" id="exception-Empty"><a href="#exception-Empty" class="anchor"></a><code><span class="keyword">exception</span> </code><code><span class="exception">Empty</span></code></dt></dl><dl><dt class="spec value" id="val-merge"><a href="#val-merge" class="anchor"></a><code><span class="keyword">val</span> merge : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Merge two heaps.</p></dd></dl><dl><dt class="spec value" id="val-insert"><a href="#val-insert" class="anchor"></a><code><span class="keyword">val</span> insert : <a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Insert a value in the heap.</p></dd></dl><dl><dt class="spec value" id="val-add"><a href="#val-add" class="anchor"></a><code><span class="keyword">val</span> add : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Synonym to <a href="index.html#val-insert"><code>insert</code></a>.</p></dd></dl><dl><dt class="spec value" id="val-filter"><a href="#val-filter" class="anchor"></a><code><span class="keyword">val</span> filter : (<a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> bool) <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Filter values, only retaining the ones that satisfy the predicate. Linear time at least.</p></dd></dl><dl><dt class="spec value" id="val-find_min"><a href="#val-find_min" class="anchor"></a><code><span class="keyword">val</span> find_min : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> option</code></dt><dd><p>Find minimal element.</p></dd></dl><dl><dt class="spec value" id="val-find_min_exn"><a href="#val-find_min_exn" class="anchor"></a><code><span class="keyword">val</span> find_min_exn : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a></code></dt><dd><p>Like <a href="index.html#val-find_min"><code>find_min</code></a> but can fail.</p><dl><dt>raises Empty</dt><dd><p>if the heap is empty.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-take"><a href="#val-take" class="anchor"></a><code><span class="keyword">val</span> take : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> (<a href="index.html#type-t">t</a> * <a href="index.html#type-elt">elt</a>) option</code></dt><dd><p>Extract and return the minimum element, and the new heap (without this element), or <code>None</code> if the heap is empty.</p></dd></dl><dl><dt class="spec value" id="val-take_exn"><a href="#val-take_exn" class="anchor"></a><code><span class="keyword">val</span> take_exn : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> * <a href="index.html#type-elt">elt</a></code></dt><dd><p>Like <a href="index.html#val-take"><code>take</code></a>, but can fail.</p><dl><dt>raises Empty</dt><dd><p>if the heap is empty.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-delete_one"><a href="#val-delete_one" class="anchor"></a><code><span class="keyword">val</span> delete_one : (<a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> bool) <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Delete one occurrence of a value if it exist in the heap. <code>delete_one eq x h</code>, use <code>eq</code> to find one <code>x</code> in <code>h</code> and delete it. If <code>h</code> do not contain <code>x</code> then it return <code>h</code>.</p><dl><dt>since</dt><dd>2.0</dd></dl></dd></dl><dl><dt class="spec value" id="val-delete_all"><a href="#val-delete_all" class="anchor"></a><code><span class="keyword">val</span> delete_all : (<a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> bool) <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Delete all occurrences of a value in the heap. <code>delete_all eq x h</code>, use <code>eq</code> to find all <code>x</code> in <code>h</code> and delete them. If <code>h</code> do not contain <code>x</code> then it return <code>h</code>. The difference with <a href="index.html#val-filter"><code>filter</code></a> is that <code>delete_all</code> stops as soon as it enters a subtree whose root is bigger than the element.</p><dl><dt>since</dt><dd>2.0</dd></dl></dd></dl><dl><dt class="spec value" id="val-iter"><a href="#val-iter" class="anchor"></a><code><span class="keyword">val</span> iter : (<a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> unit) <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt><dd><p>Iterate on elements.</p></dd></dl><dl><dt class="spec value" id="val-fold"><a href="#val-fold" class="anchor"></a><code><span class="keyword">val</span> fold : (<span class="type-var">'a</span> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> <span class="type-var">'a</span>) <span>&#45;&gt;</span> <span class="type-var">'a</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <span class="type-var">'a</span></code></dt><dd><p>Fold on all values.</p></dd></dl><dl><dt class="spec value" id="val-size"><a href="#val-size" class="anchor"></a><code><span class="keyword">val</span> size : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> int</code></dt><dd><p>Number of elements (linear complexity).</p></dd></dl><section><header><h3 id="conversions"><a href="#conversions" class="anchor"></a>Conversions</h3><p>The interface of <code>of_gen</code>, <code>of_seq</code>, <code>of_klist</code> has changed since 0.16 (the old signatures are now <code>add_seq</code>, <code>add_gen</code>, <code>add_klist</code>).</p></header><dl><dt class="spec value" id="val-to_list"><a href="#val-to_list" class="anchor"></a><code><span class="keyword">val</span> to_list : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> list</code></dt><dd><p>Return the elements of the heap, in no particular order.</p></dd></dl><dl><dt class="spec value" id="val-to_list_sorted"><a href="#val-to_list_sorted" class="anchor"></a><code><span class="keyword">val</span> to_list_sorted : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> list</code></dt><dd><p>Return the elements in increasing order.</p><dl><dt>since</dt><dd>1.1</dd></dl></dd></dl><dl><dt class="spec value" id="val-add_list"><a href="#val-add_list" class="anchor"></a><code><span class="keyword">val</span> add_list : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> list <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Add the elements of the list to the heap. An element occurring several times will be added that many times to the heap.</p><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl><dl><dt class="spec value" id="val-of_list"><a href="#val-of_list" class="anchor"></a><code><span class="keyword">val</span> of_list : <a href="index.html#type-elt">elt</a> list <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>of_list l</code> is <code>add_list empty l</code>. Complexity: <code>O(n log n)</code>.</p></dd></dl><dl><dt class="spec value" id="val-add_iter"><a href="#val-add_iter" class="anchor"></a><code><span class="keyword">val</span> add_iter : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-iter">iter</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Like <a href="index.html#val-add_list"><code>add_list</code></a>.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-add_std_seq"><a href="#val-add_std_seq" class="anchor"></a><code><span class="keyword">val</span> add_std_seq : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> Stdlib.Seq.t <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Like <a href="index.html#val-add_list"><code>add_list</code></a>.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-add_seq"><a href="#val-add_seq" class="anchor"></a><code><span class="keyword">val</span> add_seq : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-sequence">sequence</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_iter"><a href="#val-of_iter" class="anchor"></a><code><span class="keyword">val</span> of_iter : <a href="index.html#type-elt">elt</a> <a href="../index.html#type-iter">iter</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Build a heap from a given <code>iter</code>. Complexity: <code>O(n log n)</code>.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-of_std_seq"><a href="#val-of_std_seq" class="anchor"></a><code><span class="keyword">val</span> of_std_seq : <a href="index.html#type-elt">elt</a> Stdlib.Seq.t <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Build a heap from a given <code>Seq.t</code>. Complexity: <code>O(n log n)</code>.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-of_seq"><a href="#val-of_seq" class="anchor"></a><code><span class="keyword">val</span> of_seq : <a href="index.html#type-elt">elt</a> <a href="../index.html#type-sequence">sequence</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-to_iter"><a href="#val-to_iter" class="anchor"></a><code><span class="keyword">val</span> to_iter : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-iter">iter</a></code></dt><dd><p>Return a <code>iter</code> of the elements of the heap.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-to_std_seq"><a href="#val-to_std_seq" class="anchor"></a><code><span class="keyword">val</span> to_std_seq : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> Stdlib.Seq.t</code></dt><dd><p>Return a <code>Seq.t</code> of the elements of the heap.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-to_seq"><a href="#val-to_seq" class="anchor"></a><code><span class="keyword">val</span> to_seq : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-sequence">sequence</a></code></dt><dt class="spec value" id="val-to_iter_sorted"><a href="#val-to_iter_sorted" class="anchor"></a><code><span class="keyword">val</span> to_iter_sorted : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-iter">iter</a></code></dt><dd><p>Iterate on the elements, in increasing order.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-to_std_seq_sorted"><a href="#val-to_std_seq_sorted" class="anchor"></a><code><span class="keyword">val</span> to_std_seq_sorted : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> Stdlib.Seq.t</code></dt><dd><p>Iterate on the elements, in increasing order.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-to_seq_sorted"><a href="#val-to_seq_sorted" class="anchor"></a><code><span class="keyword">val</span> to_seq_sorted : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-sequence">sequence</a></code></dt><dt class="spec value" id="val-add_klist"><a href="#val-add_klist" class="anchor"></a><code><span class="keyword">val</span> add_klist : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-klist">klist</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl><dl><dt class="spec value" id="val-of_klist"><a href="#val-of_klist" class="anchor"></a><code><span class="keyword">val</span> of_klist : <a href="index.html#type-elt">elt</a> <a href="../index.html#type-klist">klist</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Build a heap from a given <code>klist</code>. Complexity: <code>O(n log n)</code>.</p></dd></dl><dl><dt class="spec value" id="val-to_klist"><a href="#val-to_klist" class="anchor"></a><code><span class="keyword">val</span> to_klist : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-klist">klist</a></code></dt><dd><p>Return a <code>klist</code> of the elements of the heap.</p></dd></dl><dl><dt class="spec value" id="val-add_gen"><a href="#val-add_gen" class="anchor"></a><code><span class="keyword">val</span> add_gen : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-gen">gen</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl><dl><dt class="spec value" id="val-of_gen"><a href="#val-of_gen" class="anchor"></a><code><span class="keyword">val</span> of_gen : <a href="index.html#type-elt">elt</a> <a href="../index.html#type-gen">gen</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Build a heap from a given <code>gen</code>. Complexity: <code>O(n log n)</code>.</p></dd></dl><dl><dt class="spec value" id="val-to_gen"><a href="#val-to_gen" class="anchor"></a><code><span class="keyword">val</span> to_gen : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-gen">gen</a></code></dt><dd><p>Return a <code>gen</code> of the elements of the heap.</p></dd></dl><dl><dt class="spec value" id="val-to_tree"><a href="#val-to_tree" class="anchor"></a><code><span class="keyword">val</span> to_tree : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-ktree">ktree</a></code></dt><dd><p>Return a <code>ktree</code> of the elements of the heap.</p></dd></dl><dl><dt class="spec value" id="val-to_string"><a href="#val-to_string" class="anchor"></a><code><span class="keyword">val</span> to_string : ?&#8288;sep:string <span>&#45;&gt;</span> (<a href="index.html#type-elt">elt</a> <span>&#45;&gt;</span> string) <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> string</code></dt><dd><p>Print the heap in a string</p><dl><dt>since</dt><dd>2.7</dd></dl></dd></dl><dl><dt class="spec value" id="val-pp"><a href="#val-pp" class="anchor"></a><code><span class="keyword">val</span> pp : ?&#8288;sep:string <span>&#45;&gt;</span> <a href="index.html#type-elt">elt</a> <a href="../index.html#type-printer">printer</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <a href="../index.html#type-printer">printer</a></code></dt><dd><p>Printer. Renamed from <code>print</code> since 2.0</p><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl></section></div></body></html>