mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCRef.swap
This commit is contained in:
parent
9beab5c3e6
commit
e9b9ed1d92
2 changed files with 9 additions and 0 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue