<!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="Zed_utf8.html"> <link rel="next" href="Zed_edit.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 modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Zed_utf8" rel="Chapter" href="Zed_utf8.html"> <link title="Zed_rope" rel="Chapter" href="Zed_rope.html"> <link title="Zed_edit" rel="Chapter" href="Zed_edit.html"> <link title="Zed_cursor" rel="Chapter" href="Zed_cursor.html"> <link title="Zed_lines" rel="Chapter" href="Zed_lines.html"> <link title="Zed_re" rel="Chapter" href="Zed_re.html"> <link title="Zed_input" rel="Chapter" href="Zed_input.html"> <link title="Zed_macro" rel="Chapter" href="Zed_macro.html"><link title="Construction" rel="Section" href="#6_Construction"> <link title="Informations" rel="Section" href="#6_Informations"> <link title="To/from strings" rel="Section" href="#6_Tofromstrings"> <link title="Random access" rel="Section" href="#6_Randomaccess"> <link title="Rope manipulation" rel="Section" href="#6_Ropemanipulation"> <link title="Iteration, folding and mapping" rel="Section" href="#6_Iterationfoldingandmapping"> <link title="Iteration and folding on leafs" rel="Section" href="#6_Iterationandfoldingonleafs"> <link title="Zippers" rel="Section" href="#6_Zippers"> <link title="Buffers" rel="Section" href="#6_Buffers"> <title>Zed_rope</title> </head> <body> <div class="navbar"><a class="pre" href="Zed_utf8.html" title="Zed_utf8">Previous</a> <a class="up" href="index.html" title="Index">Up</a> <a class="post" href="Zed_edit.html" title="Zed_edit">Next</a> </div> <h1>Module <a href="type_Zed_rope.html">Zed_rope</a></h1> <pre><span class="keyword">module</span> Zed_rope: <code class="code">sig</code> <a href="Zed_rope.html">..</a> <code class="code">end</code></pre><div class="info module top"> Unicode ropes<br> </div> <hr width="100%"> <pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> </pre> <div class="info "> Type of unicode ropes.<br> </div> <pre><span id="TYPErope"><span class="keyword">type</span> <code class="type"></code>rope</span> = <code class="type"><a href="Zed_rope.html#TYPEt">t</a></code> </pre> <div class="info "> Alias.<br> </div> <pre><span id="EXCEPTIONOut_of_bounds"><span class="keyword">exception</span> Out_of_bounds</span></pre> <div class="info "> Exception raised when trying to access a character which is outside the bounds of a rope.<br> </div> <br> <h6 id="6_Construction">Construction</h6><br> <pre><span id="VALempty"><span class="keyword">val</span> empty</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> The empty rope.<br> </div> <pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type">int -> CamomileLibrary.UChar.t -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">make length char</code> creates a rope of length <code class="code">length</code> containing only <code class="code">char</code>.<br> </div> <pre><span id="VALinit"><span class="keyword">val</span> init</span> : <code class="type">int -> (int -> CamomileLibrary.UChar.t) -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">init n f</code> returns the contenation of <code class="code">singleton (f 0)</code>, <code class="code">singleton (f 1)</code>, ..., <code class="code">singleton (f (n - 1))</code>.<br> </div> <pre><span id="VALrev_init"><span class="keyword">val</span> rev_init</span> : <code class="type">int -> (int -> CamomileLibrary.UChar.t) -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rev_init n f</code> returns the contenation of <code class="code">singleton (f (n - 1))</code>, ..., <code class="code">singleton (f 1)</code>, <code class="code">singleton (f 0)</code>.<br> </div> <pre><span id="VALsingleton"><span class="keyword">val</span> singleton</span> : <code class="type">CamomileLibrary.UChar.t -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">singleton ch</code> creates a rope of length 1 containing only <code class="code">ch</code>.<br> </div> <br> <h6 id="6_Informations">Informations</h6><br> <pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> int</code></pre><div class="info "> Returns the length of the given rope.<br> </div> <pre><span id="VALis_empty"><span class="keyword">val</span> is_empty</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> bool</code></pre><div class="info "> <code class="code">is_empty rope</code> returns whether <code class="code">str</code> is the empty rope or not.<br> </div> <pre><span id="VALcompare"><span class="keyword">val</span> compare</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a> -> int</code></pre><div class="info "> Compares two ropes (in code point order).<br> </div> <pre><span id="VALequal"><span class="keyword">val</span> equal</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a> -> bool</code></pre><div class="info "> <code class="code">equal r1 r2</code> retuns <code class="code">true</code> iff <code class="code">r1</code> is equal to <code class="code">r2</code>.<br> </div> <br> <h6 id="6_Tofromstrings">To/from strings</h6><br> <pre><span id="VALof_string"><span class="keyword">val</span> of_string</span> : <code class="type">string -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">of_string str</code> creates a rope from a string. The string must be UTF-8 encoded and is validated. Note that <code class="code">str</code> must not be modified after this operation, if you intend to do so you must copy it before passing it to <code class="code">of_string</code>.<br> </div> <pre><span id="VALto_string"><span class="keyword">val</span> to_string</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> string</code></pre><div class="info "> <code class="code">to_string rope</code> flatten a rope into a string encoded in UTF-8.<br> </div> <br> <h6 id="6_Randomaccess">Random access</h6><br> <pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> int -> CamomileLibrary.UChar.t</code></pre><div class="info "> <code class="code">get str rope</code> returns the character at index <code class="code">idx</code> in <code class="code">rope</code>.<br> </div> <br> <h6 id="6_Ropemanipulation">Rope manipulation</h6><br> <pre><span id="VALappend"><span class="keyword">val</span> append</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> Concatenates the two given ropes.<br> </div> <pre><span id="VALconcat"><span class="keyword">val</span> concat</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a> list -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">concat sep l</code> concatenates all strings of <code class="code">l</code> separating them by <code class="code">sep</code>.<br> </div> <pre><span id="VALsub"><span class="keyword">val</span> sub</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> int -> int -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">sub rope ofs len</code> Returns the sub-rope of <code class="code">rope</code> starting at <code class="code">ofs</code> and of length <code class="code">len</code>.<br> </div> <pre><span id="VALbreak"><span class="keyword">val</span> break</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> int -> <a href="Zed_rope.html#TYPEt">t</a> * <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">break rope pos</code> returns the sub-ropes before and after <code class="code">pos</code> in <code class="code">rope</code>. It is more efficient than creating two sub-ropes with <a href="Zed_rope.html#VALsub"><code class="code">Zed_rope.sub</code></a>.<br> </div> <pre><span id="VALbefore"><span class="keyword">val</span> before</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> int -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">before rope pos</code> returns the sub-rope before <code class="code">pos</code> in <code class="code">rope</code>.<br> </div> <pre><span id="VALafter"><span class="keyword">val</span> after</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> int -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">after rope pos</code> returns the sub-string after <code class="code">pos</code> in <code class="code">rope</code>.<br> </div> <pre><span id="VALinsert"><span class="keyword">val</span> insert</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> int -> <a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">insert rope pos sub</code> inserts <code class="code">sub</code> in <code class="code">rope</code> at position <code class="code">pos</code>.<br> </div> <pre><span id="VALremove"><span class="keyword">val</span> remove</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> int -> int -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">remove rope pos len</code> removes the <code class="code">len</code> characters at position <code class="code">pos</code> in <code class="code">rope</code><br> </div> <pre><span id="VALreplace"><span class="keyword">val</span> replace</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> int -> int -> <a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">replace rope pos len repl</code> replaces the <code class="code">len</code> characters at position <code class="code">pos</code> in <code class="code">rope</code> by <code class="code">repl</code>.<br> </div> <pre><span id="VALlchop"><span class="keyword">val</span> lchop</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">lchop rope</code> returns <code class="code">rope</code> without is first character. Returns <a href="Zed_rope.html#VALempty"><code class="code">Zed_rope.empty</code></a> if <code class="code">rope</code> is empty.<br> </div> <pre><span id="VALrchop"><span class="keyword">val</span> rchop</span> : <code class="type"><a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rchop rope</code> returns <code class="code">rope</code> without is last character. Returns <a href="Zed_rope.html#VALempty"><code class="code">Zed_rope.empty</code></a> if <code class="code">rope</code> is empty.<br> </div> <br> <h6 id="6_Iterationfoldingandmapping">Iteration, folding and mapping</h6><br> <pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">(CamomileLibrary.UChar.t -> unit) -> <a href="Zed_rope.html#TYPEt">t</a> -> unit</code></pre><div class="info "> <code class="code">iter f rope</code> applies <code class="code">f</code> on all characters of <code class="code">rope</code> starting from the left.<br> </div> <pre><span id="VALrev_iter"><span class="keyword">val</span> rev_iter</span> : <code class="type">(CamomileLibrary.UChar.t -> unit) -> <a href="Zed_rope.html#TYPEt">t</a> -> unit</code></pre><div class="info "> <code class="code">rev_iter f rope</code> applies <code class="code">f</code> an all characters of <code class="code">rope</code> starting from the right.<br> </div> <pre><span id="VALfold"><span class="keyword">val</span> fold</span> : <code class="type">(CamomileLibrary.UChar.t -> 'a -> 'a) -> <a href="Zed_rope.html#TYPEt">t</a> -> 'a -> 'a</code></pre><div class="info "> <code class="code">fold f rope acc</code> applies <code class="code">f</code> on all characters of <code class="code">rope</code> starting from the left, accumulating a value.<br> </div> <pre><span id="VALrev_fold"><span class="keyword">val</span> rev_fold</span> : <code class="type">(CamomileLibrary.UChar.t -> 'a -> 'a) -> <a href="Zed_rope.html#TYPEt">t</a> -> 'a -> 'a</code></pre><div class="info "> <code class="code">rev_fold f rope acc</code> applies <code class="code">f</code> on all characters of <code class="code">rope</code> starting from the right, accumulating a value.<br> </div> <pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">(CamomileLibrary.UChar.t -> CamomileLibrary.UChar.t) -><br> <a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">map f rope</code> maps all characters of <code class="code">rope</code> with <code class="code">f</code>.<br> </div> <pre><span id="VALrev_map"><span class="keyword">val</span> rev_map</span> : <code class="type">(CamomileLibrary.UChar.t -> CamomileLibrary.UChar.t) -><br> <a href="Zed_rope.html#TYPEt">t</a> -> <a href="Zed_rope.html#TYPEt">t</a></code></pre><div class="info "> <code class="code">rev_map f str</code> maps all characters of <code class="code">rope</code> with <code class="code">f</code> in reverse order.<br> </div> <br> <h6 id="6_Iterationandfoldingonleafs">Iteration and folding on leafs</h6><br> <br> Note: for all of the following functions, the leaves must absolutely not be modified.<br> <pre><span id="VALiter_leaf"><span class="keyword">val</span> iter_leaf</span> : <code class="type">(<a href="Zed_utf8.html#TYPEt">Zed_utf8.t</a> -> unit) -> <a href="Zed_rope.html#TYPEt">t</a> -> unit</code></pre><div class="info "> <code class="code">iter_leaf f rope</code> applies <code class="code">f</code> on all leaves of <code class="code">rope</code> starting from the left.<br> </div> <pre><span id="VALrev_iter_leaf"><span class="keyword">val</span> rev_iter_leaf</span> : <code class="type">(<a href="Zed_utf8.html#TYPEt">Zed_utf8.t</a> -> unit) -> <a href="Zed_rope.html#TYPEt">t</a> -> unit</code></pre><div class="info "> <code class="code">iter_leaf f rope</code> applies <code class="code">f</code> on all leaves of <code class="code">rope</code> starting from the right.<br> </div> <pre><span id="VALfold_leaf"><span class="keyword">val</span> fold_leaf</span> : <code class="type">(<a href="Zed_utf8.html#TYPEt">Zed_utf8.t</a> -> 'a -> 'a) -> <a href="Zed_rope.html#TYPEt">t</a> -> 'a -> 'a</code></pre><div class="info "> <code class="code">fold f rope acc</code> applies <code class="code">f</code> on all leaves of <code class="code">rope</code> starting from the left, accumulating a value.<br> </div> <pre><span id="VALrev_fold_leaf"><span class="keyword">val</span> rev_fold_leaf</span> : <code class="type">(<a href="Zed_utf8.html#TYPEt">Zed_utf8.t</a> -> 'a -> 'a) -> <a href="Zed_rope.html#TYPEt">t</a> -> 'a -> 'a</code></pre><div class="info "> <code class="code">rev_fold f rope acc</code> applies <code class="code">f</code> on all leaves of <code class="code">rope</code> starting from the right, accumulating a value.<br> </div> <br> <h6 id="6_Zippers">Zippers</h6><br> <pre><span class="keyword">module</span> <a href="Zed_rope.Zip.html">Zip</a>: <code class="code">sig</code> <a href="Zed_rope.Zip.html">..</a> <code class="code">end</code></pre><br> <h6 id="6_Buffers">Buffers</h6><br> <pre><span class="keyword">module</span> <a href="Zed_rope.Buffer.html">Buffer</a>: <code class="code">sig</code> <a href="Zed_rope.Buffer.html">..</a> <code class="code">end</code></pre> <pre><span class="keyword">module</span> <a href="Zed_rope.Text.html">Text</a>: <code class="type">UnicodeString.Type</code><code class="type"> with type t = rope and type index = Zip.t</code></pre><div class="info"> Camomile compatible interface </div> </body></html>