Struct strider::SliceRingImpl [] [src]

pub struct SliceRingImpl<T> {
    pub first_readable: usize,
    pub next_writable: usize,
    pub buf: Vec<T>,
}

readable area starts at first_readable and goes until next_writable. next_writable is one after the last readable and not readable.

R = first_readable
W = next_writable
o = occupied (len)
. = free

 R             W
[o o o o o o o . . . .]

Fields

index into buf of the first element that could be read. only gets incremented, never decremented. wraps around.

index into buf where the next element could we written. only gets incremented, never decremented. wraps around at buf.cap().

Methods

impl<T> SliceRingImpl<T>
[src]

ringbuffer focused on and optimized for operating on slices of values: appending to the back, reading from the front and dropping from the front. which is much faster. TODO call SliceRingImplImpl

creates an empty SliceRingImpl.

creates an empty SliceRingImpl with space for at least n elements.

returns the number of elements in the SliceRingImpl

returns the index into the underlying buffer for a given logical element index + addend

this is the most complex part Frobs the head and tail sections around to handle the fact that we just reallocated. Unsafe because it trusts old_cap.

Trait Implementations

impl<T: Clone> SliceRing<T> for SliceRingImpl<T>
[src]

appends values to the back of this ring.

removes count elements from the front of this ring. returns how many elements were removed. returns less than count if less elements are present in this ring. Read more

copies the first output.len() elements present in this ring into output. returns how many elements were copied. returns less than output.len() if there are less elements present in this ring. Read more