package containers

  1. Overview
  2. Docs
A modular, clean and powerful extension of the OCaml standard library

Install

Dune Dependency

Authors

Maintainers

Sources

containers-3.15.tbz
sha256=92143ceb4785ae5f8a07f3ab4ab9f6f32d31ead0536e9be4fdb818dd3c677e58
sha512=5fa80189d0e177af2302b48e72b70299d51fc36ac2019e1cbf389ff6a7f4705b10089405b5a719b3e4845b0d1349a47a967f865dc2e4e3f0d5a0167ef6c31431

doc/containers/CCByte_buffer/index.html

Module CCByte_bufferSource

Byte buffer.

A dynamic vector of bytes that doesn't hide its internal from you. Same use case as Buffer.t but with more power.

  • since 3.7
Sourcetype t = {
  1. mutable bs : bytes;
    (*

    The backing bytes buffer

    *)
  2. mutable len : int;
    (*

    Length of the "active" slice in bs. The actual content of the buffer is bs[0]..bs[len-1]. What comes after is undefined garbage.

    *)
}

The byte buffer. The definition is public since 3.13.1 .

Sourcetype 'a iter = ('a -> unit) -> unit
Sourceval create : ?cap:int -> unit -> t

Create a new buffer with given initial capacity.

Sourceval length : t -> int

Current length.

Sourceval is_empty : t -> bool

is_empty b is length b=0

Sourceval capacity : t -> int

Current capacity (size of the array returned by bytes)

Sourceval bytes : t -> bytes

Access the underlying byte buffer. This buffer can change after operations that affect the capacity (e.g. add_char).

Sourceval clear : t -> unit

clear buf sets buf.len <- 0. This doesn't resize the byte buffer.

Sourceval ensure_cap : t -> int -> unit

ensure_cap self n ensures that capacity self >= n.

  • raises Invalid_argument

    if this requires the buffer to grow beyond system limits.

Sourceval ensure_free : t -> int -> unit

ensure_free buf n ensures that the free space at the end of the buffer is at least n.

  • raises Invalid_argument

    if this requires the buffer to grow beyond system limits.

Sourceval shrink_to : t -> int -> unit

shrink_to buf n reduces length buf to at most n. Does nothing if the length is already <= n.

Sourceval add_char : t -> char -> unit

Push a character at the end.

  • raises Invalid_argument

    if this requires the buffer to grow beyond system limits.

Sourceval append_bytes : t -> bytes -> unit

Add bytes at the end

Sourceval append_subbytes : t -> bytes -> int -> int -> unit

Add byte slice at the end

Sourceval append_string : t -> string -> unit

Add string at the end

Sourceval append_substring : t -> string -> int -> int -> unit

Add substring at the end

Sourceval append_buf : t -> Buffer.t -> unit

Add content of the buffer at the end

Sourceval append_iter : t -> char iter -> unit

Adds characters from the iter

Sourceval append_seq : t -> char Seq.t -> unit

Adds characters from the seq

Sourceval get : t -> int -> char

Get the char at the given offset

Sourceval unsafe_get : t -> int -> char

Get the char at the given offset, unsafe (no bound check)

Sourceval set : t -> int -> char -> unit

Set the char at the given offset

Sourceval unsafe_set : t -> int -> char -> unit

Set the char at the given offset, unsafe (no bound check)

Sourceval to_slice : t -> CCByte_slice.t

to_slice buf returns a slice of the current content. The slice shares the same byte array as buf (until buf is resized).

  • since 3.13.1
Sourceval contents : t -> string

Copy the internal data to a string. Allocates.

Sourceval contents_bytes : t -> bytes

Copy the internal data to a bytes. Allocates.

Sourceval iter : (char -> unit) -> t -> unit

Iterate on the content

Sourceval iteri : (int -> char -> unit) -> t -> unit

Iterate with index.

  • since 3.13.1
Sourceval fold_left : ('a -> char -> 'a) -> 'a -> t -> 'a
Sourceval of_iter : char iter -> t
Sourceval of_seq : char Seq.t -> t
Sourceval to_iter : t -> char iter
Sourceval to_seq : t -> char Seq.t
OCaml

Innovation. Community. Security.