package batteries
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=00f34b9aed4e47f314425b2ca9ceac206f112095a17ea9a7ffa6dac8cfccc492
md5=066051f9a210277710c54ad57c3b9568
doc/batteries.unthreaded/BatArray/Cap/index.html
Module BatArray.Cap
Capabilities for arrays.
This modules provides the same set of features as Array, but with the added twist that arrays can be made read-only or write-only. Read-only arrays may then be safely shared and distributed.
There is no loss of performance involved.
Only the capability-specific functions are documented here. See the complete Array module for the documentation of other functions.
The type of arrays with capabilities. An ('a, [`Read | `Write]) array behaves as a regular 'a array, while a ('a, [`Read]) array only has read-only capabilities and a ('a, [`Write]) array only has write-only capabilities.
Base operations
val length : ('a, [> ]) t -> intval get : ('a, [> `Read ]) t -> int -> 'aval set : ('a, [> `Write ]) t -> int -> 'a -> unitConstructors
val make : int -> 'a -> ('a, _) tval create : int -> 'a -> ('a, _) tval make_float : int -> (float, _) tArray.make_float n returns a fresh float array of length n, with uninitialized data.
val of_array : 'a array -> ('a, _) tAdopt a regular array as a capability array, allowing to decrease capabilities if necessary.
This operation involves no copying. In other words, in let cap = of_array a in ..., any modification in a will also have effect on cap and reciprocally.
val to_array : ('a, [ `Read | `Write ]) t -> 'a arrayReturn a capability array as an array.
This operation requires both read and write permissions on the capability array and involves no copying. In other words, in let a = of_array cap in ..., any modification in a will also have effect on cap and reciprocally.
Drop to read-only permissions.
This operation involves no copying.
Drop to write-only permissions.
This operation involves no copying.
val init : int -> (int -> 'a) -> ('a, _) tIterators
val iter : ('a -> unit) -> ('a, [> `Read ]) t -> unitval iteri : (int -> 'a -> unit) -> ('a, [> `Read ]) t -> unitval modify : ('a -> 'a) -> ('a, [ `Read | `Write ]) t -> unitval modifyi : (int -> 'a -> 'a) -> ('a, [ `Read | `Write ]) t -> unitval fold_left : ('a -> 'b -> 'a) -> 'a -> ('b, [> `Read ]) t -> 'aval fold : ('a -> 'b -> 'a) -> 'a -> ('b, [> `Read ]) t -> 'aval fold_right : ('b -> 'a -> 'a) -> ('b, [> `Read ]) t -> 'a -> 'aval fold_while :
('acc -> 'a -> bool) ->
('acc -> 'a -> 'acc) ->
'acc ->
('a, [> `Read ]) t ->
'acc * intOperations on two arrays
Predicates
val for_all : ('a -> bool) -> ('a, [> `Read ]) t -> boolval exists : ('a -> bool) -> ('a, [> `Read ]) t -> boolval find : ('a -> bool) -> ('a, [> `Read ]) t -> 'aval mem : 'a -> ('a, [> `Read ]) t -> boolval memq : 'a -> ('a, [> `Read ]) t -> boolval findi : ('a -> bool) -> ('a, [> `Read ]) t -> intval count_matching : ('a -> bool) -> ('a, [> `Read ]) t -> intArray transformations
val rev_in_place : ('a, [ `Read | `Write ]) t -> unitval copy : ('a, [> `Read ]) t -> 'a arrayval fill : ('a, [> `Write ]) t -> int -> int -> 'a -> unitConversions
val to_list : ('a, [> `Read ]) t -> 'a listval pivot_split : 'a BatOrd.ord -> ('a, [> `Read ]) t -> 'a -> int * intval of_list : 'a list -> ('a, _) tUtilities
val sort : ('a -> 'a -> int) -> ('a, [> `Read | `Write ]) t -> unitval stable_sort : ('a -> 'a -> int) -> ('a, [ `Read | `Write ]) t -> unitval fast_sort : ('a -> 'a -> int) -> ('a, [ `Read | `Write ]) t -> unitBoilerplate code
val print :
?first:string ->
?last:string ->
?sep:string ->
('a BatIO.output -> 'b -> unit) ->
'a BatIO.output ->
('b, [> `Read ]) t ->
unitval compare : 'a BatOrd.comp -> ('a, [> `Read ]) t BatOrd.compval ord : 'a BatOrd.ord -> ('a, [> `Read ]) t BatOrd.ordOverride modules
module Exceptionless : sig ... endOperations on BatArray.Cap without exceptions.
module Labels : sig ... endOperations on BatArray.Cap with labels.