<!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="previous" href="PMap.html"> <link rel="next" href="Std.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 classes" rel=Appendix href="index_classes.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Base64" rel="Chapter" href="Base64.html"> <link title="BitSet" rel="Chapter" href="BitSet.html"> <link title="Dllist" rel="Chapter" href="Dllist.html"> <link title="DynArray" rel="Chapter" href="DynArray.html"> <link title="Enum" rel="Chapter" href="Enum.html"> <link title="ExtArray" rel="Chapter" href="ExtArray.html"> <link title="ExtHashtbl" rel="Chapter" href="ExtHashtbl.html"> <link title="ExtList" rel="Chapter" href="ExtList.html"> <link title="ExtString" rel="Chapter" href="ExtString.html"> <link title="Global" rel="Chapter" href="Global.html"> <link title="IO" rel="Chapter" href="IO.html"> <link title="OptParse" rel="Chapter" href="OptParse.html"> <link title="Option" rel="Chapter" href="Option.html"> <link title="PMap" rel="Chapter" href="PMap.html"> <link title="RefList" rel="Chapter" href="RefList.html"> <link title="Std" rel="Chapter" href="Std.html"> <link title="UChar" rel="Chapter" href="UChar.html"> <link title="UTF8" rel="Chapter" href="UTF8.html"> <link title="Unzip" rel="Chapter" href="Unzip.html"><link title="Functional Operations" rel="Section" href="#6_FunctionalOperations"> <title>RefList</title> </head> <body> <div class="navbar"><a href="PMap.html">Previous</a> <a href="index.html">Up</a> <a href="Std.html">Next</a> </div> <center><h1>Module <a href="type_RefList.html">RefList</a></h1></center> <br> <pre><span class="keyword">module</span> RefList: <code class="code">sig</code> <a href="RefList.html">..</a> <code class="code">end</code></pre>Reference on lists. <p> RefList is a extended set of functions that manipulate list references.<br> <hr width="100%"> <pre><span class="keyword">exception</span> <a name="EXCEPTIONEmpty_list"></a>Empty_list</pre> <pre><span class="keyword">exception</span> <a name="EXCEPTIONInvalid_index"></a>Invalid_index <span class="keyword">of</span> <code class="type">int</code></pre> <pre><span class="keyword">type</span> <a name="TYPEt"></a><code class="type">'a</code> t </pre> <pre><span class="keyword">val</span> <a name="VALempty"></a>empty : <code class="type">unit -> 'a <a href="RefList.html#TYPEt">t</a></code></pre><div class="info"> Returns a new empty ref list<br> </div> <pre><span class="keyword">val</span> <a name="VALis_empty"></a>is_empty : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> bool</code></pre><div class="info"> Return <code class="code">true</code> if a ref list is empty<br> </div> <pre><span class="keyword">val</span> <a name="VALclear"></a>clear : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> unit</code></pre><div class="info"> Removes all elements<br> </div> <pre><span class="keyword">val</span> <a name="VALlength"></a>length : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> int</code></pre><div class="info"> Returns the number of elements - O(n)<br> </div> <pre><span class="keyword">val</span> <a name="VALcopy"></a>copy : <code class="type">dst:'a <a href="RefList.html#TYPEt">t</a> -> src:'a <a href="RefList.html#TYPEt">t</a> -> unit</code></pre><div class="info"> Makes a copy of a ref list - O(1)<br> </div> <pre><span class="keyword">val</span> <a name="VALcopy_list"></a>copy_list : <code class="type">dst:'a <a href="RefList.html#TYPEt">t</a> -> src:'a list -> unit</code></pre><div class="info"> Makes a copy of a list - O(1)<br> </div> <pre><span class="keyword">val</span> <a name="VALcopy_enum"></a>copy_enum : <code class="type">dst:'a <a href="RefList.html#TYPEt">t</a> -> src:'a <a href="Enum.html#TYPEt">Enum.t</a> -> unit</code></pre><div class="info"> Makes a copy of a enum<br> </div> <pre><span class="keyword">val</span> <a name="VALof_list"></a>of_list : <code class="type">'a list -> 'a <a href="RefList.html#TYPEt">t</a></code></pre><div class="info"> Creates a ref list from a list - O(1)<br> </div> <pre><span class="keyword">val</span> <a name="VALto_list"></a>to_list : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a list</code></pre><div class="info"> Returns the current elements as a list - O(1)<br> </div> <pre><span class="keyword">val</span> <a name="VALof_enum"></a>of_enum : <code class="type">'a <a href="Enum.html#TYPEt">Enum.t</a> -> 'a <a href="RefList.html#TYPEt">t</a></code></pre><div class="info"> Creates a ref list from an enumeration<br> </div> <pre><span class="keyword">val</span> <a name="VALenum"></a>enum : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a <a href="Enum.html#TYPEt">Enum.t</a></code></pre><div class="info"> Returns an enumeration of current elements in the ref list<br> </div> <pre><span class="keyword">val</span> <a name="VALadd"></a>add : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info"> Adds an element at the end - O(n)<br> </div> <pre><span class="keyword">val</span> <a name="VALpush"></a>push : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info"> Adds an element at the head - O(1)<br> </div> <pre><span class="keyword">val</span> <a name="VALadd_sort"></a>add_sort : <code class="type">?cmp:('a -> 'a -> int) -> 'a <a href="RefList.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info"> Adds an element in a sorted list, using optional comparator or 'compare' as default.<br> </div> <pre><span class="keyword">val</span> <a name="VALfirst"></a>first : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info"> Returns the first element or raises <code class="code">Empty_list</code> if the ref list is empty<br> </div> <pre><span class="keyword">val</span> <a name="VALlast"></a>last : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info"> Returns the last element - O(n) or raises Empty_list if the ref list is empty<br> </div> <pre><span class="keyword">val</span> <a name="VALpop"></a>pop : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info"> Removes and returns the first element or raises <code class="code">Empty_list</code> if the ref list is empty<br> </div> <pre><span class="keyword">val</span> <a name="VALnpop"></a>npop : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> int -> 'a list</code></pre><div class="info"> Removes and returns the n first elements or raises <code class="code">Empty_list</code> if the ref list does not contain enough elements<br> </div> <pre><span class="keyword">val</span> <a name="VALhd"></a>hd : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info"> same as <code class="code">first</code><br> </div> <pre><span class="keyword">val</span> <a name="VALtl"></a>tl : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a <a href="RefList.html#TYPEt">t</a></code></pre><div class="info"> Returns a ref list containing the same elements but without the first one or raises <code class="code">Empty_list</code> if the ref list is empty<br> </div> <pre><span class="keyword">val</span> <a name="VALrev"></a>rev : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> unit</code></pre><div class="info"> Reverses the ref list - O(n)<br> </div> <br> <a name="6_FunctionalOperations"></a> <h6>Functional Operations</h6><br> <pre><span class="keyword">val</span> <a name="VALiter"></a>iter : <code class="type">('a -> unit) -> 'a <a href="RefList.html#TYPEt">t</a> -> unit</code></pre><div class="info"> Apply the given function to all elements of the ref list, in respect with the order of the list<br> </div> <pre><span class="keyword">val</span> <a name="VALfind"></a>find : <code class="type">('a -> bool) -> 'a <a href="RefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info"> Find the first element matching the specified predicate raise <code class="code">Not_found</code> if no element is found<br> </div> <pre><span class="keyword">val</span> <a name="VALrfind"></a>rfind : <code class="type">('a -> bool) -> 'a <a href="RefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info"> Find the first element in the reversed ref list matching the specified predicate raise <code class="code">Not_found</code> if no element is found<br> </div> <pre><span class="keyword">val</span> <a name="VALfind_exc"></a>find_exc : <code class="type">('a -> bool) -> exn -> 'a <a href="RefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info"> Same as find but takes an exception to be raised when no element is found as additional parameter<br> </div> <pre><span class="keyword">val</span> <a name="VALexists"></a>exists : <code class="type">('a -> bool) -> 'a <a href="RefList.html#TYPEt">t</a> -> bool</code></pre><div class="info"> Return <code class="code">true</code> if an element matches the specified predicate<br> </div> <pre><span class="keyword">val</span> <a name="VALfor_all"></a>for_all : <code class="type">('a -> bool) -> 'a <a href="RefList.html#TYPEt">t</a> -> bool</code></pre><div class="info"> Return <code class="code">true</code> if all elements match the specified predicate<br> </div> <pre><span class="keyword">val</span> <a name="VALmap"></a>map : <code class="type">('a -> 'b) -> 'a <a href="RefList.html#TYPEt">t</a> -> 'b <a href="RefList.html#TYPEt">t</a></code></pre><div class="info"> Apply a function to all elements and return the ref list constructed with the function returned values<br> </div> <pre><span class="keyword">val</span> <a name="VALtransform"></a>transform : <code class="type">('a -> 'a) -> 'a <a href="RefList.html#TYPEt">t</a> -> unit</code></pre><div class="info"> transform all elements in the ref list using a function.<br> </div> <pre><span class="keyword">val</span> <a name="VALmap_list"></a>map_list : <code class="type">('a -> 'b) -> 'a <a href="RefList.html#TYPEt">t</a> -> 'b list</code></pre><div class="info"> Apply a function to all elements and return the list constructed with the function returned values<br> </div> <pre><span class="keyword">val</span> <a name="VALsort"></a>sort : <code class="type">?cmp:('a -> 'a -> int) -> 'a <a href="RefList.html#TYPEt">t</a> -> unit</code></pre><div class="info"> Sort elements using the specified comparator or compare as default comparator<br> </div> <pre><span class="keyword">val</span> <a name="VALfilter"></a>filter : <code class="type">('a -> bool) -> 'a <a href="RefList.html#TYPEt">t</a> -> unit</code></pre><div class="info"> Remove all elements that do not match the specified predicate<br> </div> <pre><span class="keyword">val</span> <a name="VALremove"></a>remove : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info"> Remove an element from the ref list raise <code class="code">Not_found</code> if the element is not found<br> </div> <pre><span class="keyword">val</span> <a name="VALremove_if"></a>remove_if : <code class="type">('a -> bool) -> 'a <a href="RefList.html#TYPEt">t</a> -> unit</code></pre><div class="info"> Remove the first element matching the specified predicate raise <code class="code">Not_found</code> if no element has been removed<br> </div> <pre><span class="keyword">val</span> <a name="VALremove_all"></a>remove_all : <code class="type">'a <a href="RefList.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info"> Remove all elements equal to the specified element from the ref list<br> </div> <pre><span class="keyword">module</span> <a href="RefList.Index.html">Index</a>: <code class="code">sig</code> <a href="RefList.Index.html">..</a> <code class="code">end</code></pre><div class="info"> Functions that operate on the <code class="code">i</code>th element of a list. </div> </body></html>