[−][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 are built-in iterators that go from the newest items to the oldest ones and from the oldest items to the newest ones.
Two queues are considered equal if iterating over them with iter()
would yield the same
sequence of elements.
Enable the serde_support
feature for Serde support.
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
AscIter | An ascending iterator over |
AscIterMut | An mutable ascending iterator over |
Iter | An iterator over |
IterMut | A mutable iterator over |
Popped | A value popped from |