mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
258 lines
No EOL
17 KiB
HTML
258 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">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="Start" href="index.html">
|
|
<link rel="Up" href="CCRingBuffer.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"><title>Containers doc : CCRingBuffer.S</title>
|
|
</head>
|
|
<body>
|
|
<div class="navbar"> <a class="up" href="CCRingBuffer.html" title="CCRingBuffer">Up</a>
|
|
</div>
|
|
<h1>Module type <a href="type_CCRingBuffer.S.html">CCRingBuffer.S</a></h1>
|
|
|
|
<pre><span class="keyword">module type</span> S = <code class="code"><span class="keyword">sig</span></code> <a href="CCRingBuffer.S.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info modtype top">
|
|
<h2 id="2_RingBuffer">Ring Buffer</h2>
|
|
<p>
|
|
|
|
The abstract ring buffer type, made concrete by choice of
|
|
<code class="code"><span class="constructor">ARRAY</span></code> module implementation<br>
|
|
</div>
|
|
<hr width="100%">
|
|
|
|
<pre><span class="keyword">module</span> <a href="CCRingBuffer.S.Array.html">Array</a>: <code class="type"><a href="CCRingBuffer.Array.S.html">CCRingBuffer.Array.S</a></code><code class="type"> </code></pre><div class="info">
|
|
The module type of Array for this ring buffer
|
|
</div>
|
|
|
|
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> </pre>
|
|
<div class="info ">
|
|
Defines the bounded ring buffer type<br>
|
|
</div>
|
|
|
|
|
|
<pre><span id="EXCEPTIONEmpty"><span class="keyword">exception</span> Empty</span></pre>
|
|
<div class="info ">
|
|
Raised in querying functions when the buffer is empty<br>
|
|
</div>
|
|
|
|
<pre><span id="VALcreate"><span class="keyword">val</span> create</span> : <code class="type">int -> <a href="CCRingBuffer.S.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">create size</code> creates a new bounded buffer with given size.
|
|
The underlying array is allocated immediately and no further (large)
|
|
allocation will happen from now on.<br>
|
|
<b>Raises</b> <code>Invalid_argument</code> if the arguments is <code class="code">< 1</code><br>
|
|
</div>
|
|
|
|
<pre><span id="VALcopy"><span class="keyword">val</span> copy</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> <a href="CCRingBuffer.S.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Make a fresh copy of the buffer.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALcapacity"><span class="keyword">val</span> capacity</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> int</code></pre><div class="info ">
|
|
Length of the inner buffer.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> int</code></pre><div class="info ">
|
|
Number of elements currently stored in the buffer.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALis_full"><span class="keyword">val</span> is_full</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> bool</code></pre><div class="info ">
|
|
true if pushing an element would erase another element.<br>
|
|
<b>Since</b> 1.3<br>
|
|
</div>
|
|
|
|
<pre><span id="VALblit_from"><span class="keyword">val</span> blit_from</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.t -> int -> int -> unit</code></pre><div class="info ">
|
|
<code class="code">blit_from buf from_buf o len</code> copies the slice <code class="code">o, ... o + len - 1</code> from
|
|
a input buffer <code class="code">from_buf</code> to the end of the buffer.
|
|
If the slice is too large for the buffer, only the last part of the array
|
|
will be copied.<br>
|
|
<b>Raises</b> <code>Invalid_argument</code> if <code class="code">o,len</code> is not a valid slice of <code class="code">s</code><br>
|
|
</div>
|
|
|
|
<pre><span id="VALblit_into"><span class="keyword">val</span> blit_into</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.t -> int -> int -> int</code></pre><div class="info ">
|
|
<code class="code">blit_into buf to_buf o len</code> copies at most <code class="code">len</code> elements from <code class="code">buf</code>
|
|
into <code class="code">to_buf</code> starting at offset <code class="code">o</code> in <code class="code">s</code>.<br>
|
|
<b>Raises</b> <code>Invalid_argument</code> if <code class="code">o,len</code> is not a valid slice of <code class="code">s</code>.<br>
|
|
<b>Returns</b> the number of elements actually copied (<code class="code">min len (length buf)</code>).<br>
|
|
</div>
|
|
|
|
<pre><span id="VALappend"><span class="keyword">val</span> append</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> into:<a href="CCRingBuffer.S.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
|
|
<code class="code">append b ~into</code> copies all data from <code class="code">b</code> and adds it at the
|
|
end of <code class="code">into</code>. Erases data of <code class="code">into</code> if there is not enough room.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALto_list"><span class="keyword">val</span> to_list</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.elt list</code></pre><div class="info ">
|
|
Extract the current content into a list<br>
|
|
</div>
|
|
|
|
<pre><span id="VALclear"><span class="keyword">val</span> clear</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
|
|
Clear the content of the buffer. Doesn't actually destroy the content.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALis_empty"><span class="keyword">val</span> is_empty</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> bool</code></pre><div class="info ">
|
|
Is the buffer empty (i.e. contains no elements)?<br>
|
|
</div>
|
|
|
|
<pre><span id="VALjunk_front"><span class="keyword">val</span> junk_front</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
|
|
Drop the front element from <code class="code">t</code>.<br>
|
|
<b>Raises</b> <code>Empty</code> if the buffer is already empty.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALjunk_back"><span class="keyword">val</span> junk_back</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
|
|
Drop the back element from <code class="code">t</code>.<br>
|
|
<b>Raises</b> <code>Empty</code> if the buffer is already empty.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALskip"><span class="keyword">val</span> skip</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
|
|
<code class="code">skip b len</code> removes <code class="code">len</code> elements from the front of <code class="code">b</code>.<br>
|
|
<b>Raises</b> <code>Invalid_argument</code> if <code class="code">len > length b</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> f:(Array.elt -> unit) -> unit</code></pre><div class="info ">
|
|
<code class="code">iter b ~f</code> calls <code class="code">f i t</code> for each element <code class="code">t</code> in <code class="code">buf</code><br>
|
|
</div>
|
|
|
|
<pre><span id="VALiteri"><span class="keyword">val</span> iteri</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> f:(int -> Array.elt -> unit) -> unit</code></pre><div class="info ">
|
|
<code class="code">iteri b ~f</code> calls <code class="code">f i t</code> for each element <code class="code">t</code> in <code class="code">buf</code>, with <code class="code">i</code>
|
|
being its relative index within <code class="code">buf</code>.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALget_front"><span class="keyword">val</span> get_front</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> int -> Array.elt</code></pre><div class="info ">
|
|
<code class="code">get_front buf i</code> returns the <code class="code">i</code>-th element of <code class="code">buf</code> from the front, ie
|
|
the one returned by <code class="code">take_front buf</code> after <code class="code">i-1</code> calls to <code class="code">junk_front buf</code>.<br>
|
|
<b>Raises</b> <code>Invalid_argument</code> if the index is invalid (> <code class="code">length buf</code>)<br>
|
|
</div>
|
|
|
|
<pre><span id="VALget_back"><span class="keyword">val</span> get_back</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> int -> Array.elt</code></pre><div class="info ">
|
|
<code class="code">get_back buf i</code> returns the <code class="code">i</code>-th element of <code class="code">buf</code> from the back, ie
|
|
the one returned by <code class="code">take_back buf</code> after <code class="code">i-1</code> calls to <code class="code">junk_back buf</code>.<br>
|
|
<b>Raises</b> <code>Invalid_argument</code> if the index is invalid (> <code class="code">length buf</code>)<br>
|
|
</div>
|
|
|
|
<pre><span id="VALpush_back"><span class="keyword">val</span> push_back</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.elt -> unit</code></pre><div class="info ">
|
|
Push value at the back of <code class="code">t</code>.
|
|
If <code class="code">t.bounded=<span class="keyword">false</span></code>, the buffer will grow as needed,
|
|
otherwise the oldest elements are replaced first.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALpeek_front"><span class="keyword">val</span> peek_front</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.elt option</code></pre><div class="info ">
|
|
First value from front of <code class="code">t</code>, without modification.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALpeek_front_exn"><span class="keyword">val</span> peek_front_exn</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.elt</code></pre><div class="info ">
|
|
First value from front of <code class="code">t</code>, without modification.<br>
|
|
<b>Since</b> 1.3<br>
|
|
<b>Raises</b> <code>Empty</code> if buffer is empty.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALpeek_back"><span class="keyword">val</span> peek_back</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.elt option</code></pre><div class="info ">
|
|
Get the last value from back of <code class="code">t</code>, without modification.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALpeek_back_exn"><span class="keyword">val</span> peek_back_exn</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.elt</code></pre><div class="info ">
|
|
Get the last value from back of <code class="code">t</code>, without modification.<br>
|
|
<b>Since</b> 1.3<br>
|
|
<b>Raises</b> <code>Empty</code> if buffer is empty.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALtake_back"><span class="keyword">val</span> take_back</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.elt option</code></pre><div class="info ">
|
|
Take and remove the last value from back of <code class="code">t</code>, if any<br>
|
|
</div>
|
|
|
|
<pre><span id="VALtake_back_exn"><span class="keyword">val</span> take_back_exn</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.elt</code></pre><div class="info ">
|
|
Take and remove the last value from back of <code class="code">t</code>.<br>
|
|
<b>Raises</b> <code>Empty</code> if buffer is already empty.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALtake_front"><span class="keyword">val</span> take_front</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.elt option</code></pre><div class="info ">
|
|
Take and remove the first value from front of <code class="code">t</code>, if any<br>
|
|
</div>
|
|
|
|
<pre><span id="VALtake_front_exn"><span class="keyword">val</span> take_front_exn</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.elt</code></pre><div class="info ">
|
|
Take and remove the first value from front of <code class="code">t</code>.<br>
|
|
<b>Raises</b> <code>Empty</code> if buffer is already empty.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALof_array"><span class="keyword">val</span> of_array</span> : <code class="type">Array.t -> <a href="CCRingBuffer.S.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Create a buffer from an initial array, but doesn't take ownership
|
|
of it (stills allocates a new internal array)<br>
|
|
<b>Since</b> 0.11<br>
|
|
</div>
|
|
|
|
<pre><span id="VALto_array"><span class="keyword">val</span> to_array</span> : <code class="type"><a href="CCRingBuffer.S.html#TYPEt">t</a> -> Array.t</code></pre><div class="info ">
|
|
Create an array from the elements, in order.<br>
|
|
<b>Since</b> 0.11<br>
|
|
</div>
|
|
</body></html> |