package containers
Install
Dune Dependency
Authors
Maintainers
Sources
md5=03b80e963186e91ddac62ef645bf7fb2
sha512=c8f434808be540c16926bf03d89f394d33fc2d092f963a7b6d412481229e0a96290f1ad7c7d522415115d35426b7aa0b3fda4b991ddc321dad279d402c9a0c0b
doc/containers.data/CCRingBuffer/Byte/index.html
Module CCRingBuffer.Byte
Source
An efficient byte based ring buffer
The module type of Array for this ring buffer
Defines the bounded ring buffer type
Raised in querying functions when the buffer is empty
create size
creates a new bounded buffer with given size. The underlying array is allocated immediately and no further (large) allocation will happen from now on.
blit_from buf from_buf o len
copies the slice o, ... o + len - 1
from an input buffer from_buf
to the end of the buffer. If the slice is too large for the buffer, only the last part of the array will be copied.
blit_into buf to_buf o len
copies at most len
elements from buf
into to_buf
starting at offset o
in s
.
append b ~into
copies all data from b
and adds it at the end of into
. Erases data of into
if there is not enough room.
iteri b ~f
calls f i t
for each element t
in buf
, with i
being its relative index within buf
.
get_front buf i
returns the i
-th element of buf
from the front, i.e. the one returned by take_front buf
after i-1
calls to junk_front buf
.
get_back buf i
returns the i
-th element of buf
from the back, i.e. the one returned by take_back buf
after i-1
calls to junk_back buf
.
Push value at the back of t
. If t.bounded=false
, the buffer will grow as needed, otherwise the oldest elements are replaced first.
Take and remove the first value from front of t
, if any.
Create a buffer from an initial array, but doesn't take ownership of it (still allocates a new internal array).