<!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="BatRef.html"> <link rel="next" href="BatResult.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="Index of module types" rel=Appendix href="index_module_types.html"> <link title="BatArray" rel="Chapter" href="BatArray.html"> <link title="BatAvlTree" rel="Chapter" href="BatAvlTree.html"> <link title="BatBase64" rel="Chapter" href="BatBase64.html"> <link title="BatBig_int" rel="Chapter" href="BatBig_int.html"> <link title="BatBigarray" rel="Chapter" href="BatBigarray.html"> <link title="BatBitSet" rel="Chapter" href="BatBitSet.html"> <link title="BatBool" rel="Chapter" href="BatBool.html"> <link title="BatBounded" rel="Chapter" href="BatBounded.html"> <link title="BatBuffer" rel="Chapter" href="BatBuffer.html"> <link title="BatCache" rel="Chapter" href="BatCache.html"> <link title="BatChar" rel="Chapter" href="BatChar.html"> <link title="BatCharParser" rel="Chapter" href="BatCharParser.html"> <link title="BatComplex" rel="Chapter" href="BatComplex.html"> <link title="BatConcurrent" rel="Chapter" href="BatConcurrent.html"> <link title="BatDeque" rel="Chapter" href="BatDeque.html"> <link title="BatDigest" rel="Chapter" href="BatDigest.html"> <link title="BatDllist" rel="Chapter" href="BatDllist.html"> <link title="BatDynArray" rel="Chapter" href="BatDynArray.html"> <link title="BatEnum" rel="Chapter" href="BatEnum.html"> <link title="BatFile" rel="Chapter" href="BatFile.html"> <link title="BatFingerTree" rel="Chapter" href="BatFingerTree.html"> <link title="BatFloat" rel="Chapter" href="BatFloat.html"> <link title="BatFormat" rel="Chapter" href="BatFormat.html"> <link title="BatGc" rel="Chapter" href="BatGc.html"> <link title="BatGenlex" rel="Chapter" href="BatGenlex.html"> <link title="BatGlobal" rel="Chapter" href="BatGlobal.html"> <link title="BatHashcons" rel="Chapter" href="BatHashcons.html"> <link title="BatHashtbl" rel="Chapter" href="BatHashtbl.html"> <link title="BatHeap" rel="Chapter" href="BatHeap.html"> <link title="BatIMap" rel="Chapter" href="BatIMap.html"> <link title="BatIO" rel="Chapter" href="BatIO.html"> <link title="BatISet" rel="Chapter" href="BatISet.html"> <link title="BatInnerIO" rel="Chapter" href="BatInnerIO.html"> <link title="BatInnerPervasives" rel="Chapter" href="BatInnerPervasives.html"> <link title="BatInnerWeaktbl" rel="Chapter" href="BatInnerWeaktbl.html"> <link title="BatInt" rel="Chapter" href="BatInt.html"> <link title="BatInt32" rel="Chapter" href="BatInt32.html"> <link title="BatInt64" rel="Chapter" href="BatInt64.html"> <link title="BatInterfaces" rel="Chapter" href="BatInterfaces.html"> <link title="BatLazyList" rel="Chapter" href="BatLazyList.html"> <link title="BatLexing" rel="Chapter" href="BatLexing.html"> <link title="BatList" rel="Chapter" href="BatList.html"> <link title="BatLog" rel="Chapter" href="BatLog.html"> <link title="BatLogger" rel="Chapter" href="BatLogger.html"> <link title="BatMap" rel="Chapter" href="BatMap.html"> <link title="BatMarshal" rel="Chapter" href="BatMarshal.html"> <link title="BatMultiMap" rel="Chapter" href="BatMultiMap.html"> <link title="BatMultiPMap" rel="Chapter" href="BatMultiPMap.html"> <link title="BatMutex" rel="Chapter" href="BatMutex.html"> <link title="BatNativeint" rel="Chapter" href="BatNativeint.html"> <link title="BatNum" rel="Chapter" href="BatNum.html"> <link title="BatNumber" rel="Chapter" href="BatNumber.html"> <link title="BatOo" rel="Chapter" href="BatOo.html"> <link title="BatOptParse" rel="Chapter" href="BatOptParse.html"> <link title="BatOption" rel="Chapter" href="BatOption.html"> <link title="BatOrd" rel="Chapter" href="BatOrd.html"> <link title="BatParserCo" rel="Chapter" href="BatParserCo.html"> <link title="BatPathGen" rel="Chapter" href="BatPathGen.html"> <link title="BatPervasives" rel="Chapter" href="BatPervasives.html"> <link title="BatPrintexc" rel="Chapter" href="BatPrintexc.html"> <link title="BatPrintf" rel="Chapter" href="BatPrintf.html"> <link title="BatQueue" rel="Chapter" href="BatQueue.html"> <link title="BatRMutex" rel="Chapter" href="BatRMutex.html"> <link title="BatRandom" rel="Chapter" href="BatRandom.html"> <link title="BatRef" rel="Chapter" href="BatRef.html"> <link title="BatRefList" rel="Chapter" href="BatRefList.html"> <link title="BatResult" rel="Chapter" href="BatResult.html"> <link title="BatReturn" rel="Chapter" href="BatReturn.html"> <link title="BatScanf" rel="Chapter" href="BatScanf.html"> <link title="BatSeq" rel="Chapter" href="BatSeq.html"> <link title="BatSet" rel="Chapter" href="BatSet.html"> <link title="BatSplay" rel="Chapter" href="BatSplay.html"> <link title="BatStack" rel="Chapter" href="BatStack.html"> <link title="BatStream" rel="Chapter" href="BatStream.html"> <link title="BatString" rel="Chapter" href="BatString.html"> <link title="BatSubstring" rel="Chapter" href="BatSubstring.html"> <link title="BatSys" rel="Chapter" href="BatSys.html"> <link title="BatText" rel="Chapter" href="BatText.html"> <link title="BatTuple" rel="Chapter" href="BatTuple.html"> <link title="BatUChar" rel="Chapter" href="BatUChar.html"> <link title="BatUTF8" rel="Chapter" href="BatUTF8.html"> <link title="BatUnit" rel="Chapter" href="BatUnit.html"> <link title="BatUnix" rel="Chapter" href="BatUnix.html"> <link title="BatUref" rel="Chapter" href="BatUref.html"> <link title="BatVect" rel="Chapter" href="BatVect.html"> <link title="Batteries" rel="Chapter" href="Batteries.html"> <link title="BatteriesConfig" rel="Chapter" href="BatteriesConfig.html"> <link title="BatteriesPrint" rel="Chapter" href="BatteriesPrint.html"> <link title="BatteriesThread" rel="Chapter" href="BatteriesThread.html"> <link title="Extlib" rel="Chapter" href="Extlib.html"><link title="Functional Operations" rel="Section" href="#6_FunctionalOperations"> <link title="Boilerplate code" rel="Section" href="#6_Boilerplatecode"> <title>Batteries user guide : BatRefList</title> </head> <body> <div class="navbar"><a class="pre" href="BatRef.html" title="BatRef">Previous</a> <a class="up" href="index.html" title="Index">Up</a> <a class="post" href="BatResult.html" title="BatResult">Next</a> </div> <h1>Module <a href="type_BatRefList.html">BatRefList</a></h1> <pre><span class="keyword">module</span> BatRefList: <code class="code"><span class="keyword">sig</span></code> <a href="BatRefList.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top"> Reference on lists. <p> RefList is a extended set of functions that manipulate list references.<br> <b>Author(s):</b> Nicolas Cannasse, David Teller (Boilerplate code)<br> </div> <hr width="100%"> <pre><span id="EXCEPTIONEmpty_list"><span class="keyword">exception</span> Empty_list</span></pre> <pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">'a</code> t</span> </pre> <div class="info "> The type of an empty ref list<br> </div> <pre><span id="VALempty"><span class="keyword">val</span> empty</span> : <code class="type">unit -> 'a <a href="BatRefList.html#TYPEt">t</a></code></pre><div class="info "> Returns a new empty ref list<br> </div> <pre><span id="VALis_empty"><span class="keyword">val</span> is_empty</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> bool</code></pre><div class="info "> Return <code class="code"><span class="keyword">true</span></code> if a ref list is empty<br> </div> <pre><span id="VALclear"><span class="keyword">val</span> clear</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> unit</code></pre><div class="info "> Removes all elements<br> </div> <pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> int</code></pre><div class="info "> Returns the number of elements - O(n)<br> </div> <pre><span id="VALcopy"><span class="keyword">val</span> copy</span> : <code class="type">dst:'a <a href="BatRefList.html#TYPEt">t</a> -> src:'a <a href="BatRefList.html#TYPEt">t</a> -> unit</code></pre><div class="info "> Makes a copy of a ref list - O(1)<br> </div> <pre><span id="VALcopy_list"><span class="keyword">val</span> copy_list</span> : <code class="type">dst:'a <a href="BatRefList.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 id="VALcopy_enum"><span class="keyword">val</span> copy_enum</span> : <code class="type">dst:'a <a href="BatRefList.html#TYPEt">t</a> -> src:'a <a href="BatEnum.html#TYPEt">BatEnum.t</a> -> unit</code></pre><div class="info "> Makes a copy of a enum.<br> </div> <div class="param_info"><code class="code">dst</code> : A reflist, whose contents will be forgotten.</div> <pre><span id="VALof_list"><span class="keyword">val</span> of_list</span> : <code class="type">'a list -> 'a <a href="BatRefList.html#TYPEt">t</a></code></pre><div class="info "> Creates a ref list from a list - O(1)<br> </div> <pre><span id="VALto_list"><span class="keyword">val</span> to_list</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a list</code></pre><div class="info "> Returns the current elements as a list - O(1)<br> </div> <pre><span id="VALof_enum"><span class="keyword">val</span> of_enum</span> : <code class="type">'a <a href="BatEnum.html#TYPEt">BatEnum.t</a> -> 'a <a href="BatRefList.html#TYPEt">t</a></code></pre><div class="info "> Creates a ref list from an enumeration<br> </div> <pre><span id="VALenum"><span class="keyword">val</span> enum</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a <a href="BatEnum.html#TYPEt">BatEnum.t</a></code></pre><div class="info "> Returns an enumeration of current elements in the ref list<br> </div> <pre><span id="VALof_backwards"><span class="keyword">val</span> of_backwards</span> : <code class="type">'a <a href="BatEnum.html#TYPEt">BatEnum.t</a> -> 'a <a href="BatRefList.html#TYPEt">t</a></code></pre><div class="info "> Creates a ref list from an enumeration, going from last to first<br> </div> <pre><span id="VALbackwards"><span class="keyword">val</span> backwards</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a <a href="BatEnum.html#TYPEt">BatEnum.t</a></code></pre><div class="info "> Returns an enumeration of current elements in the ref list, going from last to first<br> </div> <pre><span id="VALadd"><span class="keyword">val</span> add</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info "> Adds an element at the end - O(n)<br> </div> <pre><span id="VALpush"><span class="keyword">val</span> push</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info "> Adds an element at the head - O(1)<br> </div> <pre><span id="VALadd_sort"><span class="keyword">val</span> add_sort</span> : <code class="type">cmp:('a -> 'a -> int) -> 'a <a href="BatRefList.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info "> Adds an element in a sorted list, using the given comparator.<br> </div> <pre><span id="VALfirst"><span class="keyword">val</span> first</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info "> Returns the first element or raises <code class="code"><span class="constructor">Empty_list</span></code> if the ref list is empty<br> </div> <pre><span id="VALlast"><span class="keyword">val</span> last</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info "> Returns the last element - O(n) or raises <code class="code"><span class="constructor">Empty_list</span></code> if the ref list is empty<br> </div> <pre><span id="VALpop"><span class="keyword">val</span> pop</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info "> Removes and returns the first element or raises <code class="code"><span class="constructor">Empty_list</span></code> if the ref list is empty<br> </div> <pre><span id="VALnpop"><span class="keyword">val</span> npop</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> int -> 'a list</code></pre><div class="info "> Removes and returns the n first elements or raises <code class="code"><span class="constructor">Empty_list</span></code> if the ref list does not contain enough elements<br> </div> <pre><span id="VALhd"><span class="keyword">val</span> hd</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info "> same as <code class="code">first</code><br> </div> <pre><span id="VALtl"><span class="keyword">val</span> tl</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a <a href="BatRefList.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"><span class="constructor">Empty_list</span></code> if the ref list is empty<br> </div> <pre><span id="VALrev"><span class="keyword">val</span> rev</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> unit</code></pre><div class="info "> Reverses the ref list - O(n)<br> </div> <br> <h6 id="6_FunctionalOperations">Functional Operations</h6><br> <pre><span id="VALfold_left"><span class="keyword">val</span> fold_left</span> : <code class="type">('a -> 'b -> 'a) -> 'a -> 'b <a href="BatRefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info "> <code class="code"><span class="constructor">List</span>.fold_left f a (ref [b0; b1; ...; bn])</code> is <code class="code">f (... (f (f a b0) b1) ...) bn</code>.<br> </div> <pre><span id="VALfold_right"><span class="keyword">val</span> fold_right</span> : <code class="type">('a -> 'b -> 'b) -> 'a <a href="BatRefList.html#TYPEt">t</a> -> 'b -> 'b</code></pre><div class="info "> <code class="code"><span class="constructor">List</span>.fold_right f (ref [a0; a1; ...; an]) b</code> is <code class="code">f a0 (f a1 (... (f an b) ...))</code>. Tail-recursive.<br> </div> <pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">('a -> unit) -> 'a <a href="BatRefList.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 id="VALfind"><span class="keyword">val</span> find</span> : <code class="type">('a -> bool) -> 'a <a href="BatRefList.html#TYPEt">t</a> -> 'a</code></pre><div class="info "> Find the first element matching the specified predicate raise <code class="code"><span class="constructor">Not_found</span></code> if no element is found<br> </div> <pre><span id="VALrfind"><span class="keyword">val</span> rfind</span> : <code class="type">('a -> bool) -> 'a <a href="BatRefList.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"><span class="constructor">Not_found</span></code> if no element is found<br> </div> <pre><span id="VALfind_exc"><span class="keyword">val</span> find_exc</span> : <code class="type">('a -> bool) -> exn -> 'a <a href="BatRefList.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 id="VALexists"><span class="keyword">val</span> exists</span> : <code class="type">('a -> bool) -> 'a <a href="BatRefList.html#TYPEt">t</a> -> bool</code></pre><div class="info "> Return <code class="code"><span class="keyword">true</span></code> if an element matches the specified predicate<br> </div> <pre><span id="VALfor_all"><span class="keyword">val</span> for_all</span> : <code class="type">('a -> bool) -> 'a <a href="BatRefList.html#TYPEt">t</a> -> bool</code></pre><div class="info "> Return <code class="code"><span class="keyword">true</span></code> if all elements match the specified predicate<br> </div> <pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">('a -> 'b) -> 'a <a href="BatRefList.html#TYPEt">t</a> -> 'b <a href="BatRefList.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 id="VALtransform"><span class="keyword">val</span> transform</span> : <code class="type">('a -> 'a) -> 'a <a href="BatRefList.html#TYPEt">t</a> -> unit</code></pre><div class="info "> transform all elements in the ref list using a function.<br> </div> <pre><span id="VALmap_list"><span class="keyword">val</span> map_list</span> : <code class="type">('a -> 'b) -> 'a <a href="BatRefList.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 id="VALsort"><span class="keyword">val</span> sort</span> : <code class="type">cmp:('a -> 'a -> int) -> 'a <a href="BatRefList.html#TYPEt">t</a> -> unit</code></pre><div class="info "> Sort elements using the specified comparator<br> </div> <pre><span id="VALfilter"><span class="keyword">val</span> filter</span> : <code class="type">('a -> bool) -> 'a <a href="BatRefList.html#TYPEt">t</a> -> unit</code></pre><div class="info "> Remove all elements that do not match the specified predicate<br> </div> <pre><span id="VALremove"><span class="keyword">val</span> remove</span> : <code class="type">'a <a href="BatRefList.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info "> Remove an element from the ref list raise <code class="code"><span class="constructor">Not_found</span></code> if the element is not found<br> </div> <pre><span id="VALremove_if"><span class="keyword">val</span> remove_if</span> : <code class="type">('a -> bool) -> 'a <a href="BatRefList.html#TYPEt">t</a> -> unit</code></pre><div class="info "> Remove the first element matching the specified predicate raise <code class="code"><span class="constructor">Not_found</span></code> if no element has been removed<br> </div> <pre><span id="VALremove_all"><span class="keyword">val</span> remove_all</span> : <code class="type">'a <a href="BatRefList.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> <br> <h6 id="6_Boilerplatecode">Boilerplate code</h6><br> <pre><span class="keyword">module</span> <a href="BatRefList.Index.html">Index</a>: <code class="code"><span class="keyword">sig</span></code> <a href="BatRefList.Index.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Functions that operate on the element at index <code class="code">i</code> in a list (with indices starting from 0). </div> </body></html>