package orsetto
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=151ca6df499bd3de7aa89a4e1627411fbee24c4dea6e0e71ce21f06f181ee654
md5=00393728b481c2bf15919a8202732335
doc/orsetto.cf/Cf_slice/index.html
Module Cf_slice
Slices of basic vector types, i.e. arrays, byte sequences and string.
Type
type 'a t = private {
vector : 'a;
(*The type of the underlying vector.
*)start : int;
(*Index in
*)vector
of element at start of slice.limit : int;
(*Index in
*)vector
of element after end of slice.
}
The type of a vector slice.
Constructors
val of_vector : ('a -> int) -> 'a -> 'a t
Use of_vector f v
to make a slice of v
referencing the entire range of v
starting at index zero and limiting at the index obtained by applying f v
. Raises Failure
if f
returns a negative integer.
val of_subvector : ('a -> int) -> 'a -> int -> int -> 'a t
Use of_subvector f v start limit
to make a slice that references the part of v
starting at index start
and limiting at index limit
. Raises Invalid_argument
if start > limit
or if either start
or limit
are not valid indexes in v
, where valid indexes are non-negative integers less than the result of f v
. Raises Failure
if f
returns a negative integer.
val of_array : 'a array -> 'a array t
Use of_array a
to make a slice that references all of a
.
val of_subarray : 'a array -> int -> int -> 'a array t
Use of_subarray a start limit
to make a slice that references the part of a
that starts at index start
and is limited at index limit
.
val of_bytes : bytes -> bytes t
Use of_bytes b
to make a slice that references all of b
.
val of_subbytes : bytes -> int -> int -> bytes t
Use of_subbytes b start limit
to make a slice that references the part of b
that starts at index start
and is limited at index limit
.
val of_string : string -> string t
Use of_string s
to make a slice that references all of s
.
val of_substring : string -> int -> int -> string t
Use of_substring s start limit
to make a slice that references the part of s
that starts at index start
and is limited at index limit
.
Conversions
val to_vector : ('a -> int -> int -> 'a) -> 'a t -> 'a
Use to_vector f s
to copy the values in s
into a new vector by evaluating f start length
where start
is the starting index of the slice and length
is the difference between the limit and the start.
val to_string : string t -> string
Use to_string s
to copy the octets in s
into a new string.
val to_array : 'a array t -> 'a array
Use to_array s
to copy the elements in s
into a new array.
Use to_elements s
to make a sequence of the elements in s
. Elements are read from the array as the sequence is evaluated.
Interface
val length : 'a t -> int
Use length s
to obtain the length of s
in elements.
Use truncate n s
to make a new slice that references the first n
elements in s
. Raises Invalid_argument
if n
is not a valid index into s
.
Use shift n s
to make a new slice that references the remaining elements in s
after the first n
. Raises Invalid_argument
if n
is not a valid index into s
.
Use split n s
to make two slices that reference the same mutable or immutable sequences as s
. The first slice comprises the first n
elements of s
, and the second slice comprises the remaining elements of s
. Raises Invalid_argument
if n
is not a valid index into s
.