Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Ringo.Ring
SourceRing
is a potentially useful module that is used internally to manage bounded, FIFO collections of items. The documentation is available in UNBOXED_COLLECTION
.
It is implemented as an abstraction over an array.
See Dll
for a comparison.
The type of bounded-size buffers.
add b v
adds the value v
to the buffer b
. If the buffer b
already has capacity b
values, the oldest of its values is dropped.
add_and_return_erased b v
has the same effect as add b v
but it returns the dropped value when applicable.
add_list b vs
adds each element of the list vs
in the order they appear in the list. Note that if List.length vs > capacity b
, then only the last capacity b
elements of the list remain in b
at the end.
remove_oldest b
removes and returns the oldest inserted element from the buffer b
or None
if the buffer is empty.
Note that for some collections, the removed element might still be held in memory. It will be removed eventually after other elements are added.
remove_newest b
removes and returns the most recently inserted element from the buffer b
or None
if the buffer is empty.
Note that for some collections, the removed element might still be held in memory. It will be removed eventually after other elements are added.
fold b ~init ~f
folds over the value of the buffer b
, newest to oldest.
fold_oldest_first b ~init ~f
folds over the value of the buffer b
, oldest to newest.
elements b
is a list that contains the same elements as the buffer b
, oldest first, newest last.
oldest_element b
returns the oldest inserted element from the buffer b
if any.