Module type Ringo.UNBOXED_COLLECTION
val create : int -> 'a t
create n
allocates a ring buffer that can hold up ton
values.- raises [Invalid_argument]
if
n
is 0 or less.
val capacity : 'a t -> int
capacity b
is the number of elements thatb
can hold.
val add : 'a t -> 'a -> unit
add b v
adds the valuev
to the bufferb
. If the bufferb
already hascapacity b
values, the oldest of its values is dropped.
val add_and_return_erased : 'a t -> 'a -> 'a option
add_and_return_erased b v
has the same effect asadd b v
but it returns the dropped value when applicable.
val add_list : 'a t -> 'a list -> unit
add_list b vs
adds each element of the listvs
in the order they appear in the list. Note that ifList.length vs > capacity b
, then only the lastcapacity b
elements of the list remain inb
at the end.
val clear : 'a t -> unit
clear b
removes all values from the bufferb
.
val fold : 'a t -> init:'b -> f:('b -> 'a -> 'b) -> 'b
fold b ~init ~f
folds over the value of the bufferb
, oldest to newest.
val elements : 'a t -> 'a list
elements b
is a list that contains the same elements as the bufferb
, oldest first, newest last.