ocaml-containers/1.4/CCDeque.html
2017-12-24 16:48:20 +01:00

262 lines
No EOL
15 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">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="Start" href="index.html">
<link rel="previous" href="CCPersistentHashtbl.html">
<link rel="next" href="CCFQueue.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="CCSimple_queue" rel="Chapter" href="CCSimple_queue.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="print" rel="Section" href="#2_print">
<title>Containers doc : CCDeque</title>
</head>
<body>
<div class="navbar"><a class="pre" href="CCPersistentHashtbl.html" title="CCPersistentHashtbl">Previous</a>
&nbsp;<a class="up" href="index.html" title="Index">Up</a>
&nbsp;<a class="post" href="CCFQueue.html" title="CCFQueue">Next</a>
</div>
<h1>Module <a href="type_CCDeque.html">CCDeque</a></h1>
<pre><span class="keyword">module</span> CCDeque: <code class="code"><span class="keyword">sig</span></code> <a href="CCDeque.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
<h1 id="1_Imperativedeque">Imperative deque</h1>
<p>
This structure provides fast access to its front and back elements,
with O(1) operations<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 ">
Contains 'a elements, queue in both ways<br>
</div>
<pre><span id="EXCEPTIONEmpty"><span class="keyword">exception</span> Empty</span></pre>
<pre><span id="VALcreate"><span class="keyword">val</span> create</span> : <code class="type">unit -> 'a <a href="CCDeque.html#TYPEt">t</a></code></pre><div class="info ">
New deque<br>
</div>
<pre><span id="VALclear"><span class="keyword">val</span> clear</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
Remove all elements<br>
<b>Since</b> 0.13<br>
</div>
<pre><span id="VALis_empty"><span class="keyword">val</span> is_empty</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> bool</code></pre><div class="info ">
Is the deque empty?<br>
</div>
<pre><span id="VALequal"><span class="keyword">val</span> equal</span> : <code class="type">?eq:('a -> 'a -> bool) -> 'a <a href="CCDeque.html#TYPEt">t</a> -> 'a <a href="CCDeque.html#TYPEt">t</a> -> bool</code></pre><div class="info ">
<code class="code">equal&nbsp;a&nbsp;b</code> checks whether <code class="code">a</code> and <code class="code">b</code> contain the same sequence of
elements.<br>
<b>Since</b> 0.13<br>
</div>
<div class="param_info"><code class="code">eq</code> : comparison function for elements</div>
<pre><span id="VALcompare"><span class="keyword">val</span> compare</span> : <code class="type">?cmp:('a -> 'a -> int) -> 'a <a href="CCDeque.html#TYPEt">t</a> -> 'a <a href="CCDeque.html#TYPEt">t</a> -> int</code></pre><div class="info ">
<code class="code">compare&nbsp;a&nbsp;b</code> compares lexicographically <code class="code">a</code> and <code class="code">b</code><br>
<b>Since</b> 0.13<br>
</div>
<div class="param_info"><code class="code">cmp</code> : comparison function for elements</div>
<pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> int</code></pre><div class="info ">
Number of elements
used to be linear time, now constant time<br>
</div>
<pre><span id="VALpush_front"><span class="keyword">val</span> push_front</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info ">
Push value at the front<br>
</div>
<pre><span id="VALpush_back"><span class="keyword">val</span> push_back</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info ">
Push value at the back<br>
</div>
<pre><span id="VALpeek_front"><span class="keyword">val</span> peek_front</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a</code></pre><div class="info ">
First value, or<br>
<b>Raises</b> <code>Empty</code> if empty<br>
</div>
<pre><span id="VALpeek_back"><span class="keyword">val</span> peek_back</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a</code></pre><div class="info ">
Last value, or<br>
<b>Raises</b> <code>Empty</code> if empty<br>
</div>
<pre><span id="VALtake_back"><span class="keyword">val</span> take_back</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a</code></pre><div class="info ">
Take last value, or<br>
<b>Raises</b> <code>Empty</code> if empty<br>
</div>
<pre><span id="VALtake_front"><span class="keyword">val</span> take_front</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a</code></pre><div class="info ">
Take first value, or<br>
<b>Raises</b> <code>Empty</code> if empty<br>
</div>
<pre><span id="VALappend_front"><span class="keyword">val</span> append_front</span> : <code class="type">into:'a <a href="CCDeque.html#TYPEt">t</a> -> 'a <a href="CCDeque.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
<code class="code">append_front&nbsp;~into&nbsp;q</code> adds all elements of <code class="code">q</code> at the front
of <code class="code">into</code>
O(length q) in time<br>
<b>Since</b> 0.13<br>
</div>
<pre><span id="VALappend_back"><span class="keyword">val</span> append_back</span> : <code class="type">into:'a <a href="CCDeque.html#TYPEt">t</a> -> 'a <a href="CCDeque.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
<code class="code">append_back&nbsp;~into&nbsp;q</code> adds all elements of <code class="code">q</code> at the back of <code class="code">into</code>.
O(length q) in time<br>
<b>Since</b> 0.13<br>
</div>
<pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">('a -> unit) -> 'a <a href="CCDeque.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
Iterate on elements<br>
</div>
<pre><span id="VALfold"><span class="keyword">val</span> fold</span> : <code class="type">('b -> 'a -> 'b) -> 'b -> 'a <a href="CCDeque.html#TYPEt">t</a> -> 'b</code></pre><div class="info ">
Fold on elements<br>
<b>Since</b> 0.13<br>
</div>
<br>
<h2 id="2_Conversions">Conversions</h2><br>
<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="TYPEsequence"><span class="keyword">type</span> <code class="type">'a</code> sequence</span> = <code class="type">('a -> unit) -> unit</code> </pre>
<pre><span id="VALof_seq"><span class="keyword">val</span> of_seq</span> : <code class="type">'a <a href="CCDeque.html#TYPEsequence">sequence</a> -> 'a <a href="CCDeque.html#TYPEt">t</a></code></pre><div class="info ">
Create a deque from the sequence.<br>
<b>Since</b> 0.13 optional argument [deque] disappears, use
{!add_seq_back} instead<br>
</div>
<pre><span id="VALto_seq"><span class="keyword">val</span> to_seq</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a <a href="CCDeque.html#TYPEsequence">sequence</a></code></pre><div class="info ">
iterate on the elements<br>
</div>
<pre><span id="VALof_gen"><span class="keyword">val</span> of_gen</span> : <code class="type">'a <a href="CCDeque.html#TYPEgen">gen</a> -> 'a <a href="CCDeque.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">of_gen&nbsp;g</code> makes a deque containing the elements of <code class="code">g</code><br>
<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="CCDeque.html#TYPEt">t</a> -> 'a <a href="CCDeque.html#TYPEgen">gen</a></code></pre><div class="info ">
Iterates on elements of the deque<br>
<b>Since</b> 0.13<br>
</div>
<pre><span id="VALadd_seq_front"><span class="keyword">val</span> add_seq_front</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a <a href="CCDeque.html#TYPEsequence">sequence</a> -> unit</code></pre><div class="info ">
<code class="code">add_seq_front&nbsp;q&nbsp;seq</code> adds elements of <code class="code">seq</code> into the front of <code class="code">q</code>,
in reverse order.
O(n) in time, where <code class="code">n</code> is the number of elements to add.<br>
<b>Since</b> 0.13<br>
</div>
<pre><span id="VALadd_seq_back"><span class="keyword">val</span> add_seq_back</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a <a href="CCDeque.html#TYPEsequence">sequence</a> -> unit</code></pre><div class="info ">
<code class="code">add_seq_back&nbsp;q&nbsp;seq</code> adds elements of <code class="code">seq</code> into the back of <code class="code">q</code>,
in order.
O(n) in time, where <code class="code">n</code> is the number of elements to add.<br>
<b>Since</b> 0.13<br>
</div>
<pre><span id="VALcopy"><span class="keyword">val</span> copy</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a <a href="CCDeque.html#TYPEt">t</a></code></pre><div class="info ">
Fresh copy, O(n) in time<br>
</div>
<pre><span id="VALof_list"><span class="keyword">val</span> of_list</span> : <code class="type">'a list -> 'a <a href="CCDeque.html#TYPEt">t</a></code></pre><div class="info ">
Conversion from list, in order<br>
<b>Since</b> 0.13<br>
</div>
<pre><span id="VALto_list"><span class="keyword">val</span> to_list</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a list</code></pre><div class="info ">
List of elements, in order. Less efficient than <a href="CCDeque.html#VALto_rev_list"><code class="code"><span class="constructor">CCDeque</span>.to_rev_list</code></a>.<br>
<b>Since</b> 0.13<br>
</div>
<pre><span id="VALto_rev_list"><span class="keyword">val</span> to_rev_list</span> : <code class="type">'a <a href="CCDeque.html#TYPEt">t</a> -> 'a list</code></pre><div class="info ">
Efficient conversion to list, in reverse order<br>
<b>Since</b> 0.13<br>
</div>
<br>
<h2 id="2_print">print</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="CCDeque.html#TYPEprinter">printer</a> -> 'a <a href="CCDeque.html#TYPEt">t</a> <a href="CCDeque.html#TYPEprinter">printer</a></code></pre><div class="info ">
Print the elements<br>
<b>Since</b> 0.13<br>
</div>
</body></html>