mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
229 lines
No EOL
16 KiB
HTML
229 lines
No EOL
16 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<link rel="stylesheet" href="style.css" type="text/css">
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
<link rel="Start" href="index.html">
|
|
<link rel="previous" href="CCIntMap.html">
|
|
<link rel="next" href="CCMixset.html">
|
|
<link rel="Up" href="index.html">
|
|
<link title="Index of types" rel=Appendix href="index_types.html">
|
|
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
|
|
<link title="Index of values" rel=Appendix href="index_values.html">
|
|
<link title="Index of class methods" rel=Appendix href="index_methods.html">
|
|
<link title="Index of class types" rel=Appendix href="index_class_types.html">
|
|
<link title="Index of modules" rel=Appendix href="index_modules.html">
|
|
<link title="Index of module types" rel=Appendix href="index_module_types.html">
|
|
<link title="CCVector" rel="Chapter" href="CCVector.html">
|
|
<link title="CCHeap" rel="Chapter" href="CCHeap.html">
|
|
<link title="CCList" rel="Chapter" href="CCList.html">
|
|
<link title="CCOpt" rel="Chapter" href="CCOpt.html">
|
|
<link title="CCPair" rel="Chapter" href="CCPair.html">
|
|
<link title="CCFun" rel="Chapter" href="CCFun.html">
|
|
<link title="CCHash" rel="Chapter" href="CCHash.html">
|
|
<link title="CCInt" rel="Chapter" href="CCInt.html">
|
|
<link title="CCBool" rel="Chapter" href="CCBool.html">
|
|
<link title="CCFloat" rel="Chapter" href="CCFloat.html">
|
|
<link title="CCArray" rel="Chapter" href="CCArray.html">
|
|
<link title="CCRef" rel="Chapter" href="CCRef.html">
|
|
<link title="CCSet" rel="Chapter" href="CCSet.html">
|
|
<link title="CCOrd" rel="Chapter" href="CCOrd.html">
|
|
<link title="CCRandom" rel="Chapter" href="CCRandom.html">
|
|
<link title="CCString" rel="Chapter" href="CCString.html">
|
|
<link title="CCHashtbl" rel="Chapter" href="CCHashtbl.html">
|
|
<link title="CCMap" rel="Chapter" href="CCMap.html">
|
|
<link title="CCFormat" rel="Chapter" href="CCFormat.html">
|
|
<link title="CCIO" rel="Chapter" href="CCIO.html">
|
|
<link title="CCInt64" rel="Chapter" href="CCInt64.html">
|
|
<link title="CCChar" rel="Chapter" href="CCChar.html">
|
|
<link title="CCResult" rel="Chapter" href="CCResult.html">
|
|
<link title="CCParse" rel="Chapter" href="CCParse.html">
|
|
<link title="CCArray_slice" rel="Chapter" href="CCArray_slice.html">
|
|
<link title="CCListLabels" rel="Chapter" href="CCListLabels.html">
|
|
<link title="CCArrayLabels" rel="Chapter" href="CCArrayLabels.html">
|
|
<link title="CCEqual" rel="Chapter" href="CCEqual.html">
|
|
<link title="Containers" rel="Chapter" href="Containers.html">
|
|
<link title="CCKTree" rel="Chapter" href="CCKTree.html">
|
|
<link title="CCKList" rel="Chapter" href="CCKList.html">
|
|
<link title="CCLazy_list" rel="Chapter" href="CCLazy_list.html">
|
|
<link title="CCMultiMap" rel="Chapter" href="CCMultiMap.html">
|
|
<link title="CCMultiSet" rel="Chapter" href="CCMultiSet.html">
|
|
<link title="CCTrie" rel="Chapter" href="CCTrie.html">
|
|
<link title="CCFlatHashtbl" rel="Chapter" href="CCFlatHashtbl.html">
|
|
<link title="CCCache" rel="Chapter" href="CCCache.html">
|
|
<link title="CCPersistentHashtbl" rel="Chapter" href="CCPersistentHashtbl.html">
|
|
<link title="CCDeque" rel="Chapter" href="CCDeque.html">
|
|
<link title="CCFQueue" rel="Chapter" href="CCFQueue.html">
|
|
<link title="CCBV" rel="Chapter" href="CCBV.html">
|
|
<link title="CCMixtbl" rel="Chapter" href="CCMixtbl.html">
|
|
<link title="CCMixmap" rel="Chapter" href="CCMixmap.html">
|
|
<link title="CCRingBuffer" rel="Chapter" href="CCRingBuffer.html">
|
|
<link title="CCIntMap" rel="Chapter" href="CCIntMap.html">
|
|
<link title="CCPersistentArray" rel="Chapter" href="CCPersistentArray.html">
|
|
<link title="CCMixset" rel="Chapter" href="CCMixset.html">
|
|
<link title="CCGraph" rel="Chapter" href="CCGraph.html">
|
|
<link title="CCHashSet" rel="Chapter" href="CCHashSet.html">
|
|
<link title="CCBitField" rel="Chapter" href="CCBitField.html">
|
|
<link title="CCHashTrie" rel="Chapter" href="CCHashTrie.html">
|
|
<link title="CCWBTree" rel="Chapter" href="CCWBTree.html">
|
|
<link title="CCRAL" rel="Chapter" href="CCRAL.html">
|
|
<link title="CCImmutArray" rel="Chapter" href="CCImmutArray.html">
|
|
<link title="CCHet" rel="Chapter" href="CCHet.html">
|
|
<link title="CCZipper" rel="Chapter" href="CCZipper.html">
|
|
<link title="CCPool" rel="Chapter" href="CCPool.html">
|
|
<link title="CCLock" rel="Chapter" href="CCLock.html">
|
|
<link title="CCSemaphore" rel="Chapter" href="CCSemaphore.html">
|
|
<link title="CCThread" rel="Chapter" href="CCThread.html">
|
|
<link title="CCBlockingQueue" rel="Chapter" href="CCBlockingQueue.html">
|
|
<link title="CCTimer" rel="Chapter" href="CCTimer.html">
|
|
<link title="CCUnix" rel="Chapter" href="CCUnix.html">
|
|
<link title="CCSexp" rel="Chapter" href="CCSexp.html">
|
|
<link title="CCSexp_lex" rel="Chapter" href="CCSexp_lex.html"><link title="Conversions" rel="Section" href="#2_Conversions">
|
|
<link title="IO" rel="Section" href="#2_IO">
|
|
<title>Containers doc : CCPersistentArray</title>
|
|
</head>
|
|
<body>
|
|
<div class="navbar"><a class="pre" href="CCIntMap.html" title="CCIntMap">Previous</a>
|
|
<a class="up" href="index.html" title="Index">Up</a>
|
|
<a class="post" href="CCMixset.html" title="CCMixset">Next</a>
|
|
</div>
|
|
<h1>Module <a href="type_CCPersistentArray.html">CCPersistentArray</a></h1>
|
|
|
|
<pre><span class="keyword">module</span> CCPersistentArray: <code class="code"><span class="keyword">sig</span></code> <a href="CCPersistentArray.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
|
|
<h1 id="1_PersistentArrays">Persistent Arrays</h1>
|
|
<p>
|
|
|
|
From the paper by Jean-Christophe Filliâtre,
|
|
"A persistent Union-Find data structure", see
|
|
<a href=" https://www.lri.fr/~filliatr/ftp/publis/puf-wml07.ps"> the ps version</a><br>
|
|
<b>Since</b> 0.10<br>
|
|
</div>
|
|
<hr width="100%">
|
|
|
|
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">'a</code> t</span> </pre>
|
|
<div class="info ">
|
|
The type of persistent arrays<br>
|
|
</div>
|
|
|
|
|
|
<pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type">int -> 'a -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">make n x</code> returns a persistent array of length n, with <code class="code">x</code>. All the
|
|
elements of this new array are initially physically equal to x
|
|
(in the sense of the == predicate). Consequently, if x is mutable, it is
|
|
shared among all elements of the array, and modifying x through one of the
|
|
array entries will modify all other entries at the same time.<br>
|
|
<b>Raises</b> <code>Invalid_argument</code> if <code class="code">n < 0</code> or <code class="code">n > <span class="constructor">Sys</span>.max_array_length</code>.
|
|
If the value of x is a floating-point number, then the maximum size is
|
|
only <code class="code"><span class="constructor">Sys</span>.max_array_length / 2</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALinit"><span class="keyword">val</span> init</span> : <code class="type">int -> (int -> 'a) -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">make n f</code> returns a persistent array of length n, with element
|
|
<code class="code">i</code> initialized to the result of <code class="code">f i</code>.<br>
|
|
<b>Raises</b> <code>Invalid_argument</code> if <code class="code">n < 0</code> or <code class="code">n > <span class="constructor">Sys</span>.max_array_length</code>.
|
|
If the value of x is a floating-point number, then the maximum size is
|
|
only <code class="code"><span class="constructor">Sys</span>.max_array_length / 2</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEt">t</a> -> int -> 'a</code></pre><div class="info ">
|
|
<code class="code">get a i</code> returns the element with index <code class="code">i</code> from the array <code class="code">a</code>.<br>
|
|
<b>Raises</b> <code>Invalid_argument</code> "index out of bounds" if <code class="code">n</code> is outside the
|
|
range <code class="code">0</code> to <code class="code"><span class="constructor">Array</span>.length a - 1</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALset"><span class="keyword">val</span> set</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEt">t</a> -> int -> 'a -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">set a i v</code> sets the element index <code class="code">i</code> from the array <code class="code">a</code> to <code class="code">v</code>.<br>
|
|
<b>Raises</b> <code>Invalid_argument</code> "index out of bounds" if <code class="code">n</code> is outside the
|
|
range <code class="code">0</code> to <code class="code"><span class="constructor">Array</span>.length a - 1</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEt">t</a> -> int</code></pre><div class="info ">
|
|
Returns the length of the persistent array.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALcopy"><span class="keyword">val</span> copy</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">copy a</code> returns a fresh copy of <code class="code">a</code>. Both copies are independent.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">('a -> 'b) -> 'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'b <a href="CCPersistentArray.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALmapi"><span class="keyword">val</span> mapi</span> : <code class="type">(int -> 'a -> 'b) -> 'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'b <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Applies the given function to all elements of the array, and returns
|
|
a persistent array initialized by the results of f. In the case of <code class="code">mapi</code>,
|
|
the function is also given the index of the element.
|
|
It is equivalent to <code class="code"><span class="keyword">fun</span> f t <span class="keywordsign">-></span> init (<span class="keyword">fun</span> i <span class="keywordsign">-></span> f (get t i))</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">('a -> unit) -> 'a <a href="CCPersistentArray.html#TYPEt">t</a> -> unit</code></pre>
|
|
<pre><span id="VALiteri"><span class="keyword">val</span> iteri</span> : <code class="type">(int -> 'a -> unit) -> 'a <a href="CCPersistentArray.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
|
|
<code class="code">iter f t</code> applies function <code class="code">f</code> to all elements of the persistent array,
|
|
in order from element <code class="code">0</code> to element <code class="code">length t - 1</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALfold_left"><span class="keyword">val</span> fold_left</span> : <code class="type">('a -> 'b -> 'a) -> 'a -> 'b <a href="CCPersistentArray.html#TYPEt">t</a> -> 'a</code></pre>
|
|
<pre><span id="VALfold_right"><span class="keyword">val</span> fold_right</span> : <code class="type">('a -> 'b -> 'b) -> 'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'b -> 'b</code></pre><div class="info ">
|
|
Fold on the elements of the array.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALappend"><span class="keyword">val</span> append</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Append the two arrays<br>
|
|
<b>Since</b> 0.13<br>
|
|
</div>
|
|
|
|
<pre><span id="VALflatten"><span class="keyword">val</span> flatten</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEt">t</a> <a href="CCPersistentArray.html#TYPEt">t</a> -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Concatenates all the sub-arrays<br>
|
|
<b>Since</b> 0.13<br>
|
|
</div>
|
|
|
|
<pre><span id="VALflat_map"><span class="keyword">val</span> flat_map</span> : <code class="type">('a -> 'b <a href="CCPersistentArray.html#TYPEt">t</a>) -><br> 'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'b <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Flat map (map + concatenation)<br>
|
|
<b>Since</b> 0.13<br>
|
|
</div>
|
|
|
|
<pre><span id="VALto_array"><span class="keyword">val</span> to_array</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'a array</code></pre><div class="info ">
|
|
<code class="code">to_array t</code> returns a mutable copy of <code class="code">t</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALof_array"><span class="keyword">val</span> of_array</span> : <code class="type">'a array -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">from_array a</code> returns an immutable copy of <code class="code">a</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALto_list"><span class="keyword">val</span> to_list</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'a list</code></pre><div class="info ">
|
|
<code class="code">to_list t</code> returns the list of elements in <code class="code">t</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALof_list"><span class="keyword">val</span> of_list</span> : <code class="type">'a list -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">of_list l</code> returns a fresh persistent array containing the elements of <code class="code">l</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALof_rev_list"><span class="keyword">val</span> of_rev_list</span> : <code class="type">'a list -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">of_rev_list l</code> is the same as <code class="code">of_list (<span class="constructor">List</span>.rev l)</code> but more efficient<br>
|
|
<b>Since</b> 0.13<br>
|
|
</div>
|
|
<br>
|
|
<h2 id="2_Conversions">Conversions</h2><br>
|
|
|
|
<pre><span id="TYPEsequence"><span class="keyword">type</span> <code class="type">'a</code> sequence</span> = <code class="type">('a -> unit) -> unit</code> </pre>
|
|
|
|
|
|
<pre><span id="TYPEgen"><span class="keyword">type</span> <code class="type">'a</code> gen</span> = <code class="type">unit -> 'a option</code> </pre>
|
|
|
|
|
|
<pre><span id="VALto_seq"><span class="keyword">val</span> to_seq</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'a <a href="CCPersistentArray.html#TYPEsequence">sequence</a></code></pre>
|
|
<pre><span id="VALof_seq"><span class="keyword">val</span> of_seq</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEsequence">sequence</a> -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALof_gen"><span class="keyword">val</span> of_gen</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEgen">gen</a> -> 'a <a href="CCPersistentArray.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<b>Since</b> 0.13<br>
|
|
</div>
|
|
|
|
<pre><span id="VALto_gen"><span class="keyword">val</span> to_gen</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEt">t</a> -> 'a <a href="CCPersistentArray.html#TYPEgen">gen</a></code></pre><div class="info ">
|
|
<b>Since</b> 0.13<br>
|
|
</div>
|
|
<br>
|
|
<h2 id="2_IO">IO</h2><br>
|
|
|
|
<pre><span id="TYPEprinter"><span class="keyword">type</span> <code class="type">'a</code> printer</span> = <code class="type">Format.formatter -> 'a -> unit</code> </pre>
|
|
|
|
|
|
<pre><span id="VALprint"><span class="keyword">val</span> print</span> : <code class="type">'a <a href="CCPersistentArray.html#TYPEprinter">printer</a> -><br> 'a <a href="CCPersistentArray.html#TYPEt">t</a> <a href="CCPersistentArray.html#TYPEprinter">printer</a></code></pre><div class="info ">
|
|
<b>Since</b> 0.13<br>
|
|
</div>
|
|
</body></html> |