module Flat_array: Flat_array
module Slots: Tuple_type.Slots
module Slot: Tuple_type.Slot
type 'slots
t
The type of a flat tuple array. 'slots
will look like ('a1, ..., 'an) Slots.tn
,
and the array holds tuples of type 'a1 * ... * 'an
.
include Blit.S1
include Invariant.S1
val create : ('tuple, 'a) Slots.t ->
len:int -> 'tuple -> ('tuple, 'a) Slots.t t
create slots ~len init
creates an array of len
tuples, each initialized to
init
. create
raises if len < 0
.
val copy : 'slots t -> 'slots t
copy a
returns a shallow copy of a
, that is, a fresh array containing the same
elements as a
.
val length : 'a t -> int
accessors
val slots : 'slots t -> 'slots
val get : ('b, 'v) Slots.t t -> int -> ('v, 'a) Slot.t -> 'a
get t i slot
returns tuple i
's slot
. set t i slot a
sets tuple i
's slot
to a
. As with a regular Array
, after set t i slot a
, one knows that phys_equal
a (get t i slot a)
.
val unsafe_get : ('b, 'v) Slots.t t -> int -> ('v, 'a) Slot.t -> 'a
val set : ('b, 'v) Slots.t t -> int -> ('v, 'a) Slot.t -> 'a -> unit
val unsafe_set : ('b, 'v) Slots.t t -> int -> ('v, 'a) Slot.t -> 'a -> unit
val get_tuple : ('tuple, 'a) Slots.t t -> int -> 'tuple
get_tuple t i
allocates an OCaml tuple isomorphic to the tuple at index i
in
t
.
val set_tuple : ('tuple, 'a) Slots.t t -> int -> 'tuple -> unit
val sexp_of_t : ('slots -> Sexplib.Sexp.t) -> 'slots t -> Sexplib.Sexp.t
create slots ~len init
creates an array of len
tuples, each initialized to
init
. create
raises if len < 0
.
copy a
returns a shallow copy of a
, that is, a fresh array containing the same
elements as a
.
accessors
get t i slot
returns tuple i
's slot
. set t i slot a
sets tuple i
's slot
to a
. As with a regular Array
, after set t i slot a
, one knows that phys_equal
a (get t i slot a)
.
get_tuple t i
allocates an OCaml tuple isomorphic to the tuple at index i
in
t
.