<!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=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="Up" href="Reins.Iterator.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 modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Reins" rel="Chapter" href="Reins.html"><title>Reins.Iterator.S</title> </head> <body> <div class="navbar"> <a href="Reins.Iterator.html">Up</a> </div> <center><h1>Module type <a href="type_Reins.Iterator.S.html">Reins.Iterator.S</a></h1></center> <br> <pre><span class="keyword">module type</span> S = <code class="code">sig</code> <a href="Reins.Iterator.S.html">..</a> <code class="code">end</code></pre>The signature for an iterator over an arbitrary collection<br> <hr width="100%"> <pre><span class="keyword">type</span> <a name="TYPEt"></a><code class="type">'a</code> t </pre> <div class="info"> The type of iterators. An iterator serves as a pointer into the middle of a collection. When possible, it always points to a valid element in the collection (skipping over any intermediate nodes that hold no value.<br> </div> <pre><span class="keyword">type</span> <a name="TYPEelt"></a><code class="type">'a</code> elt </pre> <div class="info"> The type of elements in the collection.<br> </div> <pre><span class="keyword">type</span> <a name="TYPEcursor"></a><code class="type">'a</code> cursor </pre> <div class="info"> The type of the cursor that points into the collection<br> </div> <pre><span class="keyword">type</span> <a name="TYPEcollection"></a><code class="type">'a</code> collection </pre> <div class="info"> The type of the collection<br> </div> <pre><span class="keyword">type</span> <a name="TYPEdirection"></a><code class="type"></code>direction </pre> <div class="info"> A type which guides the order of the traversal. Different collections may support different directions.<br> </div> <br><code><span class="keyword">type</span> <a name="TYPEtraversal"></a><code class="type">'a</code> traversal = </code><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Traverse_All</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><code class="code">Traverse_All</code> will visit every element in the collection.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Traverse_If</span> <span class="keyword">of</span> <code class="type">('a -> bool)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><code class="code">Traverse_If f</code> will traverse only those elements for which <code class="code">f</code> returns true.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Traverse_While</span> <span class="keyword">of</span> <code class="type">('a -> bool)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><code class="code">Traverse_While f</code> will traverse elements as long as <code class="code">f</code> is true.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> <div class="info"> This type defines the traversal strategy. It determines which elements will be visited by the iterator.<br> </div> <pre><span class="keyword">val</span> <a name="VALcreate"></a>create : <code class="type"><a href="Reins.Iterator.S.html#TYPEdirection">direction</a> -><br> 'a <a href="Reins.Iterator.S.html#TYPEelt">elt</a> <a href="Reins.Iterator.S.html#TYPEtraversal">traversal</a> -><br> 'a <a href="Reins.Iterator.S.html#TYPEcollection">collection</a> -> 'a <a href="Reins.Iterator.S.html#TYPEt">t</a></code></pre><div class="info"> <code class="code">create dir trav col</code> Create an iterator for the collection <code class="code">col</code> using the direction and traversal given.<br> </div> <pre><span class="keyword">val</span> <a name="VALfrom_cursor"></a>from_cursor : <code class="type"><a href="Reins.Iterator.S.html#TYPEdirection">direction</a> -><br> 'a <a href="Reins.Iterator.S.html#TYPEelt">elt</a> <a href="Reins.Iterator.S.html#TYPEtraversal">traversal</a> -><br> 'a <a href="Reins.Iterator.S.html#TYPEcursor">cursor</a> -> 'a <a href="Reins.Iterator.S.html#TYPEt">t</a></code></pre><div class="info"> <code class="code">from_cursor dir trav curs</code> Create an iterator for the collection starting at the cursor <code class="code">curs</code>. The cursor need not point to the beginning of the collection. If it does point to an element, then this element will be the first element visited by the iterator.<br> </div> <pre><span class="keyword">val</span> <a name="VALvalue"></a>value : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> 'a <a href="Reins.Iterator.S.html#TYPEelt">elt</a> option</code></pre><div class="info"> Return the element currently pointed to by the iterator. This will return <code class="code">None</code> only when the iterator has reached the end of the collection.<br> </div> <pre><span class="keyword">val</span> <a name="VALget_value"></a>get_value : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> 'a <a href="Reins.Iterator.S.html#TYPEelt">elt</a></code></pre><div class="info"> Similar to <a href="Reins.Iterator.S.html#VALvalue"><code class="code">Reins.Iterator.S.value</code></a> except it throws the exception <code class="code">Failure "get_value"</code> if the iterator has reached the end of the collection .<br> </div> <pre><span class="keyword">val</span> <a name="VALat_end"></a>at_end : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> bool</code></pre><div class="info"> Returns true if the iterator has reached the end of the collection as governed by the current traversal strategy.<br> </div> <pre><span class="keyword">val</span> <a name="VALat_beg"></a>at_beg : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> bool</code></pre><div class="info"> Returns true if the iterator is at the beginning of the collection as governed by the current traversal strategy. This is equivalent to <a href="Reins.Iterator.S.html#VALhas_prev"><code class="code">Reins.Iterator.S.has_prev</code></a>.<br> </div> <pre><span class="keyword">val</span> <a name="VALhas_next"></a>has_next : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> bool</code></pre><div class="info"> Returns true if there is another element in the traversal after the current element.<br> </div> <pre><span class="keyword">val</span> <a name="VALnext"></a>next : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> 'a <a href="Reins.Iterator.S.html#TYPEt">t</a></code></pre><div class="info"> Advances the iterator to the next element in the collection. If the iterator is at the end of the collection, it raises <code class="code">Failure "next"</code>.<br> </div> <pre><span class="keyword">val</span> <a name="VALhas_prev"></a>has_prev : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> bool</code></pre><div class="info"> Returns true if there is another element that occurs before the current element. Equivalent to <a href="Reins.Iterator.S.html#VALat_beg"><code class="code">Reins.Iterator.S.at_beg</code></a>.<br> </div> <pre><span class="keyword">val</span> <a name="VALprev"></a>prev : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> 'a <a href="Reins.Iterator.S.html#TYPEt">t</a></code></pre><div class="info"> Advances the iterator to the previous element in the collection. If the iterator is at the beginning of the collection, it raises <code class="code">Failure "prev"</code>.<br> </div> <pre><span class="keyword">val</span> <a name="VALgoto_beg"></a>goto_beg : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> 'a <a href="Reins.Iterator.S.html#TYPEt">t</a></code></pre><div class="info"> Advance the iterator to the beginning of the collection as governed by the traversal strategy<br> </div> <pre><span class="keyword">val</span> <a name="VALgoto_end"></a>goto_end : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> 'a <a href="Reins.Iterator.S.html#TYPEt">t</a></code></pre><div class="info"> Advance the iterator to the end of the collection as governed by the traversal strategy<br> </div> <pre><span class="keyword">val</span> <a name="VALflip"></a>flip : <code class="type">'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> 'a <a href="Reins.Iterator.S.html#TYPEt">t</a></code></pre><div class="info"> Reverse the direction of the iterator. All elements that were previously reachable by <code class="code">next</code> are now reachable by <code class="code">prev</code> and vice versa.<br> </div> <pre><span class="keyword">val</span> <a name="VALiter"></a>iter : <code class="type">('a <a href="Reins.Iterator.S.html#TYPEelt">elt</a> -> unit) -> 'a <a href="Reins.Iterator.S.html#TYPEt">t</a> -> unit</code></pre><div class="info"> <code class="code">iter f t</code> Apply <code class="code">f</code> to each element in the collection that satisfies the traversal strategy. If the iterator is not at the beginning of the collection, the elements reachable by <a href="Reins.Iterator.S.html#VALprev"><code class="code">Reins.Iterator.S.prev</code></a> will not be visited.<br> </div> <pre><span class="keyword">val</span> <a name="VALfold"></a>fold : <code class="type">('a -> 'b <a href="Reins.Iterator.S.html#TYPEelt">elt</a> -> 'a) -> 'a -> 'b <a href="Reins.Iterator.S.html#TYPEt">t</a> -> 'a</code></pre><div class="info"> <code class="code">fold f acc t</code> Accumulates the result <code class="code">acc</code> by applying <code class="code">f acc x</code> for each element <code class="code">x</code> in the collection that satisfies the traversal strategy. If the iterator is not at the beginning of the collection, the elements reachable by <a href="Reins.Iterator.S.html#VALprev"><code class="code">Reins.Iterator.S.prev</code></a> will not be visited.<br> </div> </body></html>