mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
Merge pull request #159 from orbifx/master
Add `CCImmutArray.sub`, which creates a copy
This commit is contained in:
commit
170d7662e7
2 changed files with 11 additions and 0 deletions
|
|
@ -27,6 +27,8 @@ let set a n x =
|
|||
a'.(n) <- x;
|
||||
a'
|
||||
|
||||
let sub = Array.sub (* Would this not be better implemented with CCArray_slice *)
|
||||
|
||||
let map = Array.map
|
||||
|
||||
let mapi = Array.mapi
|
||||
|
|
|
|||
|
|
@ -36,6 +36,15 @@ val get : 'a t -> int -> 'a
|
|||
val set : 'a t -> int -> 'a -> 'a t
|
||||
(** Copy the array and modify its copy *)
|
||||
|
||||
val sub : 'a t -> int -> int -> 'a t
|
||||
(** [sub a start len] returns a fresh array of length len, containing the elements
|
||||
from [start] to pstart + len - 1] of array a.
|
||||
|
||||
Raises [Invalid_argument "Array.sub"] if [start] and [len] do not designate a
|
||||
valid subarray of a; that is, if start < 0, or len < 0, or start + len > Array.length a.
|
||||
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val map : ('a -> 'b) -> 'a t -> 'b t
|
||||
|
||||
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue