module Buffer:sig..end
This is similar to the Buffer module in the standard library
except that it constructs ropes. It is recommended to use this
module instead of repeatedly concatenating chars.
type t
Mutable buffer to construct ropes.
val create : int -> tcreate n returns a fresh buffer, initially empty. The n
parameter is the initial size of the internal rope that holds
the buffer contents. The buffer will grow dynamically to
accomodate new inputs.
val clear : t -> unitEmpty the buffer.
val reset : t -> unitEmpty the buffer.
val length : t -> intReturn the number of characters currently contained in the buffer.
val add_char : t -> char -> unitadd_char b c appends the character c at the end of the
buffer b.
Failure if the length if the buffer exceeds max_int.val add_string : t -> string -> unitadd_string b s appends the string s at the end of the
buffer b.
Failure if the length if the buffer exceeds max_int.val add_substring : t -> string -> int -> int -> unitadd_substring b s ofs len takes len characters from offset
ofs in string s and appends them at the end of the buffer
b.
Invalid_argument if ofs and len do not designate a
valid substring of s.Failure if the length if the buffer exceeds max_int.val add_rope : t -> Rope.rope -> unitadd_rope b r add the rope r to the buffer b.
val add_channel : t -> Stdlib.in_channel -> int -> unitadd_channel b ic n reads exactly n characters from the input
channel ic and stores them at the end of buffer b.
End_of_file if the channel contains fewer than n
characters.val add_buffer : t -> t -> unitadd_buffer b1 b2 appends the current contents of buffer b2
at the end of buffer b1. b2 is not modified.
val contents : t -> Rope.ropeReturn a copy of the current contents of the buffer. The buffer itself is unchanged.
val sub : t -> int -> int -> Rope.ropesub b off len returns a rope of the current contents of the
buffer b starting at offset off of length len bytes.
The buffer itself is unaffected.
Invalid_argument if out of bounds request.val nth : t -> int -> charnth b i returns the ith character if the buffer.
Out_of_bounds if i < 0 or i >= length b.
Time: O(log(length b)).