Bigstring.SliceSourceSlices represent a contiguous portion of an array.
length t returns the number of elements in t.
val slice :
('a : value_or_null mod portable separable). ?i:Base.int ->
?j:Base.int ->
'a t ->
'a t @ local @@ portableslice ~i ~j array is a slice representing array[i..j).
val sub :
('a : value_or_null mod portable separable). ?i:Base.int ->
?j:Base.int ->
'a t @ local ->
'a t @ local @@ portablesub ~i ~j slice is a slice representing slice[i..j).
To read a value from a parallel array, we must prove that it does not escape its capsule. This is the case if its type crosses contention, or if it is manipulated within a portable function.
val get :
('a : value_or_null mod contended portable separable). 'a t @ local ->
Base.int ->
'a @@ portableget t i reads the element at index i. Raises Invalid_arg if i is not in the range [0..length t).
val unsafe_get :
('a : value_or_null mod contended portable separable). 'a t @ local ->
Base.int ->
'a @@ portableunsafe_get t i unsafely reads the element at index i.
val extract :
('a : value_or_null mod portable separable). 'a t @ local ->
Base.int ->
('a -> 'b @ portable contended) @ local once portable ->
'b @ portable contended @@ portableextract t i f applies f with the element read from index i. Raises Invalid_arg if i is not in the range [0..length t).
val unsafe_extract :
('a : value_or_null mod portable separable). 'a t @ local ->
Base.int ->
('a -> 'b @ portable contended) @ local once portable ->
'b @ portable contended @@ portableunsafe_extract t i f applies f with the element unsafely read from index i.
val fork_join2 :
('a : value_or_null mod portable separable). Parallel_kernel.t @ local ->
?pivot:Base.int ->
'a t @ local ->
(Parallel_kernel.t @ local -> ('a t @ local -> 'b) @ local once) @ local once shareable forkable ->
(Parallel_kernel.t @ local -> ('a t @ local -> 'c) @ local once) @ once shareable ->
#('b * 'c) @@ portablefork_join2 parallel ~pivot t f g splits the slice t into two sub-slices representing t[0..pivot) and t[pivot..length t), respectively. The sub-slices are passed to f and g, which run in parallel (refer to {Parallel_kernel.fork_join2}).
val for_ :
('a : value_or_null mod portable separable). Parallel_kernel.t @ local ->
pivots:Base.int Base.iarray ->
'a t @ local ->
f:(Parallel_kernel.t @ local -> 'a t @ local -> Base.unit) @ shareable ->
Base.unit @@ portablefor_ parallel ~pivots t ~f splits the slice t into multiple sub-slices representing the ranges t[0..pivots[0]), t[pivots[i]..pivots[i+1]), etc. The function f is evaluated for each sub-slice in parallel. pivots must be non-decreasing, but may have duplicate elements, resulting in empty sub-slices.
val fori :
('a : value_or_null mod portable separable). Parallel_kernel.t @ local ->
pivots:Base.int Base.iarray ->
'a t @ local ->
f:
(Parallel_kernel.t @ local -> Base.int -> 'a t @ local -> Base.unit) @ shareable ->
Base.unit @@ portablefori parallel ~pivots t ~f splits the slice t into multiple sub-slices representing the ranges t[0..pivots[0]), t[pivots[i]..pivots[i+1]), etc. The function f is evaluated for each sub-slice and its index in parallel. pivots must be non-decreasing, but may have duplicate elements.
To read a value from a parallel array, we must prove that it does not escape its capsule. This is the case if its type crosses contention, or if it is manipulated within a portable function.
To store a value in a parallel array, we must prove that it does not share unsynchronized state with any other elements. This is the case if its type crosses contention or it lives in a fresh capsule.
val set :
('a : value_or_null mod contended portable separable). 'a t @ local ->
Base.int ->
'a ->
Base.unit @@ portableset t i a stores the element a at index i. Raises Invalid_arg if i is not in the range [0..length t).
val unsafe_set :
('a : value_or_null mod contended portable separable). 'a t @ local ->
Base.int ->
'a ->
Base.unit @@ portableunsafe_insert t i f unsafely stores f a at index i.