add CCRef.swap

This commit is contained in:
Simon Cruanes 2017-09-22 17:52:24 +02:00
parent 9beab5c3e6
commit e9b9ed1d92
2 changed files with 9 additions and 0 deletions

View file

@ -32,6 +32,11 @@ let compare f r1 r2 = f !r1 !r2
let equal f r1 r2 = f !r1 !r2
let swap a b =
let x = !a in
a := !b;
b := x
let to_list r = [!r]
let to_seq r yield = yield !r

View file

@ -31,6 +31,10 @@ val get_then_incr : int t -> int
(** [get_then_incr r] increments [r] and returns its old value, think [r++]
@since 0.17 *)
val swap : 'a t -> 'a t -> unit
(** Swap values.
@since NEXT_RELEASE *)
val compare : 'a ord -> 'a t ord
val equal : 'a eq -> 'a t eq