Library
Module
Module type
Parameter
Class
Class type
Typed arrays.
module Buffer : sig ... end
ArrayBuffer
objects (byte buffers).
module Data_view : sig ... end
DataView objects
(byte-level typed data access on ArrayBuffer
s).
type ('a, 'b) type' =
| Int8 : (int, Bigarray.int8_signed_elt) type'
| Int16 : (int, Bigarray.int16_signed_elt) type'
| Int32 : (int32, Bigarray.int32_elt) type'
| Uint8 : (int, Bigarray.int8_unsigned_elt) type'
| Uint8_clamped : (int, Bigarray.int8_unsigned_elt) type'
| Uint16 : (int, Bigarray.int16_unsigned_elt) type'
| Uint32 : (int32, Bigarray.int32_elt) type'
| Float32 : (float, Bigarray.float32_elt) type'
| Float64 : (float, Bigarray.float64_elt) type'
The type for typed array whose elements are of type 'b
and are accessed with type 'a
.
val type_size_in_bytes : ('a, 'b) type' -> int
type_size_in_bytes t
is the number of bytes used to store an element of type 'b
.
Note. In the functions below.
length
. This means that -1
denotes the last element of the buffer.start
defaults to 0
.stop
defaults to length b
.The type for ArrayBufferView
objects (typed access to ArrayBuffer
objects) whose elements are of type 'b
and accessed with type 'a
. See the type aliases.
create n t
is an array of type t
with n
elements of type 'b
initialised to their zero. See also converting.
of_buffer t ~byte_offset ~length b
is an array of type t
with length
elements of type 'b
starting at the byte offset byte_offset
of b
. byte_offset
defaults to 0
and length so as to get to the end of the buffer.
val byte_offset : ('a, 'b) t -> int
byte_offset a
is the byte index where a
starts in buffer a
.
val byte_length : ('a, 'b) t -> int
byte_length a
is the byte length of a
.
val length : ('a, 'b) t -> int
length a
are the number of elements in a
.
val get : ('a, 'b) t -> int -> 'a
get a i
is the element of a
at i
.
val set : ('a, 'b) t -> int -> 'a -> unit
set a i v
sets the element of a
at i
to v
.
set_tarray a ~dst b
sets the values of a
starting at index dst
with those of b
which are converted to match the type of a
(unclear how exactly).
val fill : ?start:int -> ?stop:int -> 'a -> ('a, 'b) t -> unit
fill ~start ~stop v a
sets the elements in range [start];[stop-1]
to v
.
val copy_within : ?start:int -> ?stop:int -> dst:int -> ('a, 'b) t -> unit
copy_within ~start ~stop ~dst a
copies at at dst
the elements in range [start];[stop-1]
.
slice ~start ~stop a
is a new array holding a copy of the bytes of a
in range [start
;stop-1
]. This is a copy, use sub
to share the data.
sub ~start ~stop a
is an array that spans the bytes of b
in range [start
;stop-1
]. This is not a copy, use slice
to make a copy.
val find : (int -> 'a -> bool) -> ('a, 'b) t -> 'a option
find sat a
is the first index a.i
for which sat i a.[i]
is true.
val find_index : (int -> 'a -> bool) -> ('a, 'b) t -> int option
find sat a
is the first index i for which sat i a.[i]
is true.
val for_all : (int -> 'a -> bool) -> ('a, 'b) t -> bool
for_all sat a
is true
iff all elements a.[i]
of b
satisfy sat i a.[i]
.
val exists : (int -> 'a -> bool) -> ('a, 'b) t -> bool
exists sat a
is true
iff one elements a.[i]
of b
satisfies sat i a.[i]
.
filter sat a
is an array with the elements a.[i]
of a
for which sat i a.[i]
is true
.
val iter : (int -> 'a -> unit) -> ('a, 'b) t -> unit
iter f a
calls f i a.[i]
on each element of a
.
map f a
is a new typed array with elements of a
mapped by f
.
val fold_left : ('c -> 'a -> 'c) -> 'c -> ('a, 'b) t -> 'c
fold_left f acc a
folds f
over the elements of a
starting with acc
.
val fold_right : ('a -> 'c -> 'c) -> ('a, 'b) t -> 'c -> 'c
fold_right f acc a
folds f
over the elements of a
starting with acc
.
Use these in interfaces.
type int8 = (int, Bigarray.int8_signed_elt) t
type int16 = (int, Bigarray.int16_signed_elt) t
type int32 = (Int32.t, Bigarray.int32_elt) t
type uint8 = (int, Bigarray.int8_unsigned_elt) t
type uint8_clamped = (int, Bigarray.int8_unsigned_elt) t
type uint16 = (int, Bigarray.int16_unsigned_elt) t
type uint32 = (Int32.t, Bigarray.int32_elt) t
type float32 = (float, Bigarray.float32_elt) t
type float64 = (float, Bigarray.float64_elt) t
of_tarray t a
is an array of type t
with the elements of a
converted accordingly (unclear how exactly).
of_int_array t arr
is an array of type t
whose elements are the values of arr
, values exceeding the range for the type are taken modulo the range bounds (except for Uint8_clamped
).
of_int_array t arr
is an array of type t
whose elements are the values of arr
, values exceeding the range for the type are taken modulo the range bounds (except for Uint8_clamped
).
val to_jstr : uint8 -> (Jstr.t, Jv.Error.t) result
to_jstr a
is the UTF-8 encoded data a
as a string. Errors if a
holds invalid UTF-8.
val of_binary_jstr : Jstr.t -> (uint8, Jv.Error.t) result
of_binary_jstr s
is an unsigned byte array with the bytes of the JavaScript binary string s
. Errors if a code unit of s
is greater than 255
.
to_binary_jstr a
is a JavaScript binary string with the unsigned bytes of a
.
to_int_jstr ~sep a
is a string with the elements of a
printed and separated by sep
(defaults to Jstr.sp
).
to_hex_jstr ?sep a
is a string with the bytes of a
printed in lowercase hex and separated by sep
(defaults to Jstr.empty
).
val to_string : uint8 -> string
to_string a
is an OCaml byte string from the byte array.
val type_to_bigarray_kind : ('a, 'b) type' -> ('a, 'b) Bigarray.kind
type_to_bigarray_kind t
is t
as a bigarray kind. Uint32
is mapped on Bigarray.int32
.
val type_of_bigarray_kind : ('a, 'b) Bigarray.kind -> ('a, 'b) type' option
type_of_bigarray_kind k
is k
as a type array type or None
if there is no corresponding one.
val bigarray_kind : ('a, 'b) t -> ('a, 'b) Bigarray.kind
bigarray_kind a
is the bigarray kind of a
.
val of_bigarray1 : ('a, 'b, Bigarray.c_layout) Bigarray.Array1.t -> ('a, 'b) t
of_bigarray1 b
is a typed array with the data of bigarray b
. The data buffer is shared.
val to_bigarray1 : ('a, 'b) t -> ('a, 'b, Bigarray.c_layout) Bigarray.Array1.t
to_bigarray b
is a bigarray with the data of bigarray b
. The data buffer is shared.
val of_bigarray : ('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t -> ('a, 'b) t
of_bigarray b
is a typed array with the data of bigarray b
. The data buffer is shared. XXX. How is the data laid out ?