[][src]Crate circular_queue

A circular buffer-like queue.

The CircularQueue<T> is created with a set capacity, then items are pushed in. When the queue runs out of capacity, newer items start overwriting the old ones, starting from the oldest.

There's a built-in iterator that goes from the newest items to the oldest ones.

Two queues are considered equal if iterating over them would yield the same sequence of elements.

Examples

use circular_queue::CircularQueue;

let mut queue = CircularQueue::with_capacity(3);
queue.push(1);
queue.push(2);
queue.push(3);
queue.push(4);

assert_eq!(queue.len(), 3);

let mut iter = queue.iter();

assert_eq!(iter.next(), Some(&4));
assert_eq!(iter.next(), Some(&3));
assert_eq!(iter.next(), Some(&2));

Structs

CircularQueue

A circular buffer-like queue.

Type Definitions

Iter

An iterator over CircularQueue<T>.

IterMut

A mutable iterator over CircularQueue<T>.