Utils: add Ring.clear
This commit is contained in:
parent
bb90cc9dec
commit
9b09e70f5e
@ -40,6 +40,12 @@ let add_and_return_erased r v =
|
||||
None in
|
||||
add r v ; replaced
|
||||
|
||||
let clear r =
|
||||
match !r with
|
||||
| Empty _ -> ()
|
||||
| Inited { data ; _ } ->
|
||||
r := Empty (Array.length data)
|
||||
|
||||
let add_list r l = List.iter (add r) l
|
||||
|
||||
let last r =
|
||||
|
@ -27,6 +27,9 @@ val add_and_return_erased : 'a t -> 'a -> 'a option
|
||||
(** Adds the values of a list, in order. *)
|
||||
val add_list : 'a t -> 'a list -> unit
|
||||
|
||||
(** Removes all values in the ring buffer. *)
|
||||
val clear : 'a t -> unit
|
||||
|
||||
(** Retrieves the most recent value, or [None] when empty. *)
|
||||
val last : 'a t -> 'a option
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user