package brr
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=49e7bfbad2ea6a0139354e4a33c59c8a113c4c1e20a4f629bc5cad24aa801e474b4af10ce35adbda5d23dd294d1de5efa5b10bb3030d03f4758459977250a0f6
doc/brr/Brr/Tarray/index.html
Module Brr.TarraySource
Typed arrays.
Buffers
DataView objects (byte-level typed data access on ArrayBuffers).
Array types
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.
type_size_in_bytes t is the number of bytes used to store an element of type 'b.
Typed arrays
Note. In the functions below.
- Indices can always be negative in which case they are subtracted from
length. This means that-1denotes the last element of the buffer. - If unspecified
startdefaults to0. - If unspecified
stopdefaults tolength 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.
byte_offset a is the byte index where a starts in buffer a.
Setting, copying and slicing
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).
fill ~start ~stop v a sets the elements in range [start];[stop-1] to v.
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.
Predicates
find sat a is the first index a.i for which sat i a.[i] is true.
find sat a is the first index i for which sat i a.[i] is true.
for_all sat a is true iff all elements a.[i] of b satisfy sat i a.[i].
exists sat a is true iff one elements a.[i] of b satisfies sat i a.[i].
Traversals
filter sat a is an array with the elements a.[i] of a for which sat i a.[i] is true.
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.
fold_left f acc a folds f over the elements of a starting with acc.
fold_right f acc a folds f over the elements of a starting with acc.
Type aliases
Use these in interfaces.
Converting
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).
With strings
of_jstr s is an unsigned byte array with s as UTF-8 encoded data.
to_jstr a is the UTF-8 encoded data a as a string. Errors if a holds invalid UTF-8.
of_binary_jstr s is an unsigned byte array with the bytes of the binary string s. In s every byte is represented by a code unit in the range [0;255]. Errors if a code unit of s is greater than 255.
to_binary_jstr a converts a to a binary string, a string in which every byte is represented by a code unit in the range [0;255].
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).
As bigarrays
type_to_bigarray_kind t is t as a bigarray kind. Uint32 is mapped on Bigarray.int32.
type_of_bigarray_kind k is k as a type array type or None if there is no corresponding one.
bigarray_kind a is the bigarray kind of a.
of_bigarray1 b is a typed array with the data of bigarray b. The data buffer is shared.
to_bigarray b is a bigarray with the data of bigarray b. The data buffer is shared.
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 ?