mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 19:25:28 -05:00
ccpersistentArray.copy
This commit is contained in:
parent
adee01be65
commit
76f966aed3
2 changed files with 6 additions and 1 deletions
|
|
@ -49,6 +49,8 @@ let reroot t = match !t with
|
|||
| Array a -> a
|
||||
| _ -> _reroot t (fun x -> x)
|
||||
|
||||
let copy t = ref (Array(Array.copy (reroot t)))
|
||||
|
||||
let get t i = match !t with
|
||||
| Array a -> a.(i)
|
||||
| _ -> (reroot t).(i)
|
||||
|
|
|
|||
|
|
@ -65,9 +65,12 @@ val set : 'a t -> int -> 'a -> 'a t
|
|||
val length : 'a t -> int
|
||||
(** Returns the length of the persistent array. *)
|
||||
|
||||
val copy : 'a t -> 'a t
|
||||
(** [copy a] returns a fresh copy of [a]. Both copies are independent. *)
|
||||
|
||||
val map : ('a -> 'b) -> 'a t -> 'b t
|
||||
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
|
||||
(** Applies the given function to all elements of the array, and returns
|
||||
(** Applies the given function to all elements of the array, and returns
|
||||
a persistent array initialized by the results of f. In the case of [mapi],
|
||||
the function is also given the index of the element.
|
||||
It is equivalent to [fun f t -> init (fun i -> f (get t i))]. *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue