ocaml-containers/dev/CCArray.S.html
2016-08-22 10:17:49 +02:00

229 lines
No EOL
17 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="next" href="CCArray.MONO_ARRAY.html">
<link rel="Up" href="CCArray.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="CCPrint" rel="Chapter" href="CCPrint.html">
<link title="CCError" rel="Chapter" href="CCError.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="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="CCHashconsedSet" rel="Chapter" href="CCHashconsedSet.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="CCBloom" rel="Chapter" href="CCBloom.html">
<link title="CCWBTree" rel="Chapter" href="CCWBTree.html">
<link title="CCRAL" rel="Chapter" href="CCRAL.html">
<link title="CCAllocCache" rel="Chapter" href="CCAllocCache.html">
<link title="CCImmutArray" rel="Chapter" href="CCImmutArray.html">
<link title="CCHet" rel="Chapter" href="CCHet.html">
<link title="Containers_string" rel="Chapter" href="Containers_string.html">
<link title="CCKMP" rel="Chapter" href="CCKMP.html">
<link title="CCLevenshtein" rel="Chapter" href="CCLevenshtein.html">
<link title="CCApp_parse" rel="Chapter" href="CCApp_parse.html">
<link title="CCParse" rel="Chapter" href="CCParse.html">
<link title="CCBigstring" rel="Chapter" href="CCBigstring.html">
<link title="CCArray1" rel="Chapter" href="CCArray1.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="Containers_advanced" rel="Chapter" href="Containers_advanced.html">
<link title="CCLinq" rel="Chapter" href="CCLinq.html">
<link title="CCBatch" rel="Chapter" href="CCBatch.html">
<link title="CCCat" rel="Chapter" href="CCCat.html">
<link title="CCMonadIO" rel="Chapter" href="CCMonadIO.html">
<link title="Containers_io_is_deprecated" rel="Chapter" href="Containers_io_is_deprecated.html">
<link title="CCUnix" rel="Chapter" href="CCUnix.html">
<link title="CCSexp" rel="Chapter" href="CCSexp.html">
<link title="CCSexpM" rel="Chapter" href="CCSexpM.html"><link title="IO" rel="Section" href="#2_IO">
<title>Containers doc : CCArray.S</title>
</head>
<body>
<div class="navbar">&nbsp;<a class="up" href="CCArray.html" title="CCArray">Up</a>
&nbsp;<a class="post" href="CCArray.MONO_ARRAY.html" title="CCArray.MONO_ARRAY">Next</a>
</div>
<h1>Module type <a href="type_CCArray.S.html">CCArray.S</a></h1>
<pre><span class="keyword">module type</span> S = <code class="code"><span class="keyword">sig</span></code> <a href="CCArray.S.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><hr width="100%">
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">'a</code> t</span> </pre>
<div class="info ">
Array, or sub-array, containing elements of type <code class="code"><span class="keywordsign">'</span>a</code><br>
</div>
<pre><span id="VALempty"><span class="keyword">val</span> empty</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a></code></pre>
<pre><span id="VALequal"><span class="keyword">val</span> equal</span> : <code class="type">'a <a href="CCArray.html#TYPEequal">CCArray.equal</a> -> 'a <a href="CCArray.S.html#TYPEt">t</a> <a href="CCArray.html#TYPEequal">CCArray.equal</a></code></pre>
<pre><span id="VALcompare"><span class="keyword">val</span> compare</span> : <code class="type">'a <a href="CCArray.html#TYPEord">CCArray.ord</a> -> 'a <a href="CCArray.S.html#TYPEt">t</a> <a href="CCArray.html#TYPEord">CCArray.ord</a></code></pre>
<pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> int -> 'a</code></pre>
<pre><span id="VALget_safe"><span class="keyword">val</span> get_safe</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> int -> 'a option</code></pre><div class="info ">
<code class="code">get_safe a i</code> returns <code class="code"><span class="constructor">Some</span> a.(i)</code> if <code class="code">i</code> is a valid index<br>
<b>Since</b> 0.18<br>
</div>
<pre><span id="VALset"><span class="keyword">val</span> set</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> int -> 'a -> unit</code></pre>
<pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> int</code></pre>
<pre><span id="VALfold"><span class="keyword">val</span> fold</span> : <code class="type">('a -> 'b -> 'a) -> 'a -> 'b <a href="CCArray.S.html#TYPEt">t</a> -> 'a</code></pre>
<pre><span id="VALfoldi"><span class="keyword">val</span> foldi</span> : <code class="type">('a -> int -> 'b -> 'a) -> 'a -> 'b <a href="CCArray.S.html#TYPEt">t</a> -> 'a</code></pre><div class="info ">
Fold left on array, with index<br>
</div>
<pre><span id="VALfold_while"><span class="keyword">val</span> fold_while</span> : <code class="type">('a -> 'b -> 'a * [ `Continue | `Stop ]) -> 'a -> 'b <a href="CCArray.S.html#TYPEt">t</a> -> 'a</code></pre><div class="info ">
Fold left on array until a stop condition via <code class="code">(<span class="keywordsign">'</span>a, <span class="keywordsign">`</span><span class="constructor">Stop</span>)</code> is
indicated by the accumulator<br>
<b>Since</b> 0.8<br>
</div>
<pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">('a -> unit) -> 'a <a href="CCArray.S.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="CCArray.S.html#TYPEt">t</a> -> unit</code></pre>
<pre><span id="VALblit"><span class="keyword">val</span> blit</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> int -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> int -> int -> unit</code></pre><div class="info ">
<code class="code">blit from i into j len</code> copies <code class="code">len</code> elements from the first array
to the second. See <code class="code"><span class="constructor">Array</span>.blit</code>.<br>
</div>
<pre><span id="VALreverse_in_place"><span class="keyword">val</span> reverse_in_place</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
Reverse the array in place<br>
</div>
<pre><span id="VALfind"><span class="keyword">val</span> find</span> : <code class="type">('a -> 'b option) -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> 'b option</code></pre><div class="info ">
<code class="code">find f a</code> returns <code class="code"><span class="constructor">Some</span> y</code> if there is an element <code class="code">x</code> such
that <code class="code">f x = <span class="constructor">Some</span> y</code>, else it returns <code class="code"><span class="constructor">None</span></code><br>
</div>
<pre><span id="VALfindi"><span class="keyword">val</span> findi</span> : <code class="type">(int -> 'a -> 'b option) -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> 'b option</code></pre><div class="info ">
Like <a href="CCArray.S.html#VALfind"><code class="code"><span class="constructor">CCArray</span>.<span class="constructor">S</span>.find</code></a>, but also pass the index to the predicate function.<br>
<b>Since</b> 0.3.4<br>
</div>
<pre><span id="VALfind_idx"><span class="keyword">val</span> find_idx</span> : <code class="type">('a -> bool) -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> (int * 'a) option</code></pre><div class="info ">
<code class="code">find_idx p x</code> returns <code class="code"><span class="constructor">Some</span> (i,x)</code> where <code class="code">x</code> is the <code class="code">i</code>-th element of <code class="code">l</code>,
and <code class="code">p x</code> holds. Otherwise returns <code class="code"><span class="constructor">None</span></code><br>
<b>Since</b> 0.3.4<br>
</div>
<pre><span id="VALlookup"><span class="keyword">val</span> lookup</span> : <code class="type">?cmp:'a <a href="CCArray.html#TYPEord">CCArray.ord</a> -> 'a -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> int option</code></pre><div class="info ">
Lookup the index of some value in a sorted array.<br>
<b>Returns</b> <code class="code"><span class="constructor">None</span></code> if the key is not present, or
<code class="code"><span class="constructor">Some</span> i</code> (<code class="code">i</code> the index of the key) otherwise<br>
</div>
<pre><span id="VALlookup_exn"><span class="keyword">val</span> lookup_exn</span> : <code class="type">?cmp:'a <a href="CCArray.html#TYPEord">CCArray.ord</a> -> 'a -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> int</code></pre><div class="info ">
Same as <a href="CCArray.S.html#VALlookup_exn"><code class="code"><span class="constructor">CCArray</span>.<span class="constructor">S</span>.lookup_exn</code></a>, but<br>
<b>Raises</b> <code>Not_found</code> if the key is not present<br>
</div>
<pre><span id="VALbsearch"><span class="keyword">val</span> bsearch</span> : <code class="type">?cmp:('a -> 'a -> int) -><br> 'a -><br> 'a <a href="CCArray.S.html#TYPEt">t</a> -><br> [ `All_bigger | `All_lower | `At of int | `Empty | `Just_after of int ]</code></pre><div class="info ">
<code class="code">bsearch ?cmp x arr</code> finds the index of the object <code class="code">x</code> in the array <code class="code">arr</code>,
provided <code class="code">arr</code> is <b>sorted</b> using <code class="code">cmp</code>. If the array is not sorted,
the result is not specified (may raise Invalid_argument).
<p>
Complexity: O(log n) where n is the length of the array
(dichotomic search).<br>
<b>Since</b> 0.13<br>
<b>Raises</b> <code>Invalid_argument</code> if the array is found to be unsorted w.r.t <code class="code">cmp</code><br>
<b>Returns</b> - <code class="code"><span class="keywordsign">`</span><span class="constructor">At</span> i</code> if <code class="code">cmp arr.(i) x = 0</code> (for some i)<ul>
<li><code class="code"><span class="keywordsign">`</span><span class="constructor">All_lower</span></code> if all elements of <code class="code">arr</code> are lower than <code class="code">x</code></li>
<li><code class="code"><span class="keywordsign">`</span><span class="constructor">All_bigger</span></code> if all elements of <code class="code">arr</code> are bigger than <code class="code">x</code></li>
<li><code class="code"><span class="keywordsign">`</span><span class="constructor">Just_after</span> i</code> if <code class="code">arr.(i) &lt; x &lt; arr.(i+1)</code></li>
<li><code class="code"><span class="keywordsign">`</span><span class="constructor">Empty</span></code> if the array is empty</li>
</ul>
<br>
</div>
<pre><span id="VALfor_all"><span class="keyword">val</span> for_all</span> : <code class="type">('a -> bool) -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> bool</code></pre>
<pre><span id="VALfor_all2"><span class="keyword">val</span> for_all2</span> : <code class="type">('a -> 'a -> bool) -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> bool</code></pre><div class="info ">
Forall on pairs of arrays.<br>
<b>Raises</b> <code>Invalid_argument</code> if they have distinct lengths<br>
</div>
<pre><span id="VALexists"><span class="keyword">val</span> exists</span> : <code class="type">('a -> bool) -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> bool</code></pre>
<pre><span id="VALexists2"><span class="keyword">val</span> exists2</span> : <code class="type">('a -> 'a -> bool) -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> bool</code></pre><div class="info ">
Exists on pairs of arrays.<br>
<b>Raises</b> <code>Invalid_argument</code> if they have distinct lengths<br>
</div>
<pre><span id="VALshuffle"><span class="keyword">val</span> shuffle</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
Shuffle randomly the array, in place<br>
</div>
<pre><span id="VALshuffle_with"><span class="keyword">val</span> shuffle_with</span> : <code class="type">Random.State.t -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
Like shuffle but using a specialized random state<br>
</div>
<pre><span id="VALrandom_choose"><span class="keyword">val</span> random_choose</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> 'a <a href="CCArray.html#TYPErandom_gen">CCArray.random_gen</a></code></pre><div class="info ">
Choose an element randomly.<br>
<b>Raises</b> <code>Not_found</code> if the array/slice is empty<br>
</div>
<pre><span id="VALto_seq"><span class="keyword">val</span> to_seq</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> 'a <a href="CCArray.html#TYPEsequence">CCArray.sequence</a></code></pre>
<pre><span id="VALto_gen"><span class="keyword">val</span> to_gen</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> 'a <a href="CCArray.html#TYPEgen">CCArray.gen</a></code></pre>
<pre><span id="VALto_klist"><span class="keyword">val</span> to_klist</span> : <code class="type">'a <a href="CCArray.S.html#TYPEt">t</a> -> 'a <a href="CCArray.html#TYPEklist">CCArray.klist</a></code></pre><br>
<h2 id="2_IO">IO</h2><br>
<pre><span id="VALpp"><span class="keyword">val</span> pp</span> : <code class="type">?sep:string -> (Buffer.t -> 'a -> unit) -> Buffer.t -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
Print an array of items with printing function<br>
</div>
<pre><span id="VALpp_i"><span class="keyword">val</span> pp_i</span> : <code class="type">?sep:string -><br> (Buffer.t -> int -> 'a -> unit) -> Buffer.t -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
Print an array, giving the printing function both index and item<br>
</div>
<pre><span id="VALprint"><span class="keyword">val</span> print</span> : <code class="type">?sep:string -><br> (Format.formatter -> 'a -> unit) -><br> Format.formatter -> 'a <a href="CCArray.S.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
Print an array of items with printing function<br>
</div>
</body></html>