mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -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,6 +65,9 @@ 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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue