A homogeneous numeric array stored as a contiguous binary buffer.
Encoding emits tag 0x0C (TypedArray): element type, element count,
alignment padding and the raw little-endian buffer. Decoding with
typed_arrays: :views returns this struct so callers can read the raw
bytes without per-element copies.
Examples
iex> ta = Btoon.TypedArray.new(:float64, <<1.5::64-little-float, 2.5::64-little-float>>)
iex> Btoon.TypedArray.type(ta)
:float64
iex> Btoon.TypedArray.to_list(ta)
[1.5, 2.5]
Summary
Functions
Returns the raw buffer.
Builds a typed array from a list of numbers, picking the narrowest type
that represents every value losslessly (:int8..:int64 for integers,
:float32/:float64 for floats).
Number of elements in the typed array.
Builds a typed array from a raw buffer.
Converts the raw buffer into a list of numbers.
Returns the element type atom.
Types
@type t() :: %ToonEx.Btoon.TypedArray{ data: binary(), type: ToonEx.Btoon.Types.element_type() }
Functions
Returns the raw buffer.
Builds a typed array from a list of numbers, picking the narrowest type
that represents every value losslessly (:int8..:int64 for integers,
:float32/:float64 for floats).
@spec length(t()) :: non_neg_integer()
Number of elements in the typed array.
@spec new(ToonEx.Btoon.Types.element_type(), binary()) :: t()
Builds a typed array from a raw buffer.
The buffer length must be a multiple of the element size of type.
Converts the raw buffer into a list of numbers.
@spec type(t()) :: ToonEx.Btoon.Types.element_type()
Returns the element type atom.