Module Kappa_generic_toolset.Bigbuffer
type bigstring= (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.ttype tThe abstract type of buffers.
val create : int -> tcreate nreturns a fresh buffer, initially empty. Thenparameter is the initial size of the internal byte sequence that holds the buffer contents. That byte sequence is automatically reallocated when more thanncharacters are stored in the buffer, but shrinks back toncharacters whenresetis called. For best performance,nshould be of the same order of magnitude as the number of characters that are expected to be stored in the buffer (for instance, 80 for a buffer that holds one output line). Nothing bad will happen if the buffer grows beyond that limit, however. In doubt, taken = 16for instance. Ifnis not between 1 andSys.max_string_length, it will be clipped to that interval.
val contents : t -> bigstringReturn a copy of the current contents of the buffer. The buffer itself is unchanged.
val add_char : t -> char -> unitadd_char b cappends the charactercat the end of bufferb.
val length : t -> intReturn the number of characters currently contained in the buffer.
val add_string : t -> string -> unitadd_string b sappends the stringsat the end of bufferb.
val add_substring : t -> string -> int -> int -> unitadd_substring b s ofs lentakeslencharacters from offsetofsin stringsand appends them at the end of bufferb.
val add_subbytes : t -> bytes -> int -> int -> unitadd_subbytes b s ofs lentakeslencharacters from offsetofsin byte sequencesand appends them at the end of bufferb.- since
- 4.02
val nth : t -> int -> charGet the n-th character of the buffer. Raise
Invalid_argumentif index out of bounds
val clear : t -> unitEmpty the buffer.
val reset : t -> unitEmpty the buffer and deallocate the internal byte sequence holding the buffer contents, replacing it with the initial internal byte sequence of length
nthat was allocated byBuffer.createn. For long-lived buffers that may have grown a lot,resetallows faster reclamation of the space used by the buffer.