Struct fixed_circular_buffer::CircularBuffer [] [src]

pub struct CircularBuffer<T, L = Box<[T]>> { /* fields omitted */ }

Fixed size circular/cyclic/ring buffer

Almost a FIFO (first in, first out) queue. · It cannot represent an empty buffer. · The queue is always filled (Cannot dequeue without queueing).

When constructed, the internal list must not be empty.

Methods

impl<T, L> CircularBuffer<T, L>
[src]

[src]

Constructs the structure from its raw components.

Unsafety

This function is unsafe as there is no guarantee that first < list.len(), nor whether list is non-empty.

[src]

Deconstructs the structure into its raw components

impl<T, L> CircularBuffer<T, L> where
    L: Deref<Target = [T]>, 
[src]

[src]

Returns the number of elements (before starting to loop around).

[src]

Returns an iterator over the buffer looping around at the end. This iterator is initially iterating from the most recently queued element to the oldest, and then looping around (relative to queue). This creates a never ending iterator

[src]

Returns an iterator over the buffer without looping around. Iterates from the most recently queued element to the oldest queued element (relative to queue).

[src]

[src]

Returns a reference to the element at the given index. Smaller indices are more recently queued elements (relative to queue) (0 is the newest). When index is out of range, it loops around.

[src]

impl<T, L> CircularBuffer<T, L> where
    L: DerefMut<Target = [T]>, 
[src]

[src]

Swaps the most recently queued element.

[src]

Enqueues (push at beginning) the given element at the beginning of the buffer. Dequeues (pop at end) the last element and returns it.

[src]

Sets the offset for the first element, relative to the currently first element. Smaller indices are more recently queued elements (relative to queue) (0 is the newest). When index is out of range, it loops around.

[src]

Returns a mutable reference to the element at the given index. Smaller indices are more recently queued elements (relative to queue) (0 is the newest). When index is out of range, it loops around.

[src]

Swaps the two elements at the given indices a and b. Smaller indices are more recently queued elements (relative to queue) (0 is the newest). When a or b are out of range, they loop around.

[src]

Swaps the element at the given index with the specifiied new one. When a or b are out of range, they loop around.

[src]

Trait Implementations

impl<T: Copy, L: Copy> Copy for CircularBuffer<T, L>
[src]

impl<T: Clone, L: Clone> Clone for CircularBuffer<T, L>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: Debug, L: Debug> Debug for CircularBuffer<T, L>
[src]

[src]

Formats the value using the given formatter. Read more

impl<T: Eq, L: Eq> Eq for CircularBuffer<T, L>
[src]

impl<T: PartialEq, L: PartialEq> PartialEq for CircularBuffer<T, L>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<T: Hash, L: Hash> Hash for CircularBuffer<T, L>
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<T> From<Vec<T>> for CircularBuffer<T>
[src]

[src]

Constructs an already filled circular buffer from the elements in a vec. The first element in the Vec will be interpreted as the most reecntly queued element, and the last element as the oldest.

impl<T, L> From<L> for CircularBuffer<T, L> where
    L: Deref<Target = [T]>, 
[src]

[src]

Performs the conversion.

impl<T> FromIterator<T> for CircularBuffer<T>
[src]

[src]

Creates a value from an iterator. Read more